1.

Solve : .bat file to end a process...?

Answer»

Can someone please help me? I'm trying to find a command line that will end a process like when you open task manager and go to the process TAB and end processes. The reasoning is when I run my virus removal software it tells me to end a few things and it would just be easier to click a .bat file then to bring up task-manager ..please help A similar question appeared earlier this week. I guess some code just never dies.

Code: [Select]@echo off
:loop
for /f "tokens=1 skip=3" %%f in ('tasklist') do (
if /i .%%f equ .%1 taskkill /im %1 /f
)
if not .%2==. (
shift
goto loop
)

Save the above snippet with a bat extension. You can then run your batch file to KILL any number of jobs named on the command line.

ie: If you saved the file as RunTheKill, you could run it as:

RunTheKill excel.exe iexplore.exe

Both Excel and Internet Explorer will be killed.

Good luck. it says tasklist is not recognized as .... am i supposed to put the tasks in there?Apparently my crystal ball was not PLUGGED in. Tasklist and Taskkill are utilities installed with some NT operating systems. (Note: XP Home has TLIST).

You can download both from here

Happy coding.

Next time please mention your OS. You'd be surprised how helpful that little piece of information can be.What would the code be for Windows Server 2003?It's FLATTERING you would drag up an OLD post from 11 months ago. Gives new meaning to Groundhog Day.

Windows XP pre-dates Windows Server 2003. Seems reasonable taskkill and tasklist would be included with the newer OS. The snippet has been slightly modified from the original.

Code: [Select]@echo off
:loop
for /f "tokens=1-2" %%f in ('tasklist') do (
if /i %%f equ %1.exe taskkill /F /IM %%f 2>nul
)
if .%2==. goto :eof
shift
goto loop




Thanks so much!



Discussion

No Comment Found