kill processes one by one using .bat

pekzz alex

Estimable
Mar 5, 2014
1
0
4,510
0
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 .
 

hang-the-9

Titan
Moderator
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.
 
Thread starter Similar threads Forum Replies Date
G Apps General Discussion 7
D Apps General Discussion 1
P Apps General Discussion 5
J Apps General Discussion 2
R Apps General Discussion 5
sponge_b0b Apps General Discussion 3
R Apps General Discussion 8
L Apps General Discussion 3
R Apps General Discussion 2
B Apps General Discussion 2
Achint2000 Apps General Discussion 4
M Apps General Discussion 3
B Apps General Discussion 5
kol12 Apps General Discussion 9
A Apps General Discussion 1
A Apps General Discussion 3
M Apps General Discussion 3
N Apps General Discussion 2
A Apps General Discussion 2
sadab0 Apps General Discussion 1

ASK THE COMMUNITY