Tuesday, April 30, 2013

Terminate multiple processes at a time on windows machine

Terminating multiple tasks from task manager one at a time could be troublesome.
Use the below to kill multiple processes by running a command.
1. Open command prompt
2.   2. type    taskkill /f /im processname.exe
·             ex: taskkill /f /im java.exe
That's it. 

To check if the process is running or not and then terminate,please use below batchscript:
Below code wil first check if the firefox instance is open, only then it kills.

tasklist /FI "IMAGENAME eq firefox.exe" /FO CSV > search.log
FOR /F %%A IN (search.log) DO IF %%A EQU 0 GOTO end

del search.log
taskkill /f /im firefox.exe
exit 0

No comments:

Post a Comment