kill processes one by one using .bat

pekzz alex

Estimable
Mar 5, 2014
1
0
4,510
I want to kill process "example.exe" one by one or two at a time to eventually get 0 "example.exe" processes and loop check if there's any "example.exe" processes every minute , if there is - terminate them/it. Right now I'm using this

:TASKKILL
TASKKILL /F /IM WerFault.exe
ping 1.1.1.1 -n 1 -w 120000
goto :TASKKILL

but this just kills them all at the same time which is no good to me .
 
If you are trying to kill processes with the same name, you'll need to use the PID number as that should be unique.

"Use tasklist to determine the Process ID (PID) for the process to be terminated. "
tasklist /fi "Imagename eq WerFault.exe" will give you the PID for those processes and you can parse that into a command to kill them by PID.