Reputation: 1893
I am working on one batch script where I need to kill the PID of the top row "chrome.exe pid: 2880 TSH\C400677" can someone let me know how could I do that? I think I need to use for loop.First I need to save the output of the below command and then take first row and from there fetch the PID and kill it.
Is it possible than I can do it in a single commands.Use below command and kill the PID of the all the process one by one.?
C:\Users\C400677\Desktop\Handle>Handle.exe -p chrome | find /I "pid"
chrome.exe pid: 2880 TSH\C400677
chrome.exe pid: 6404 TSH\C400677
chrome.exe pid: 3572 TSH\C400677
chrome.exe pid: 5348 TSH\C400677
Upvotes: 2
Views: 1542
Reputation: 57252
This will kill only the first process in the list:
@echo off
for /f "tokens=3 delims= " %%# in ('Handle.exe -p chrome^|find /I "pid"') do (
tskill %%#
goto :break_for
)
:break_for
NOT TESTED!!
remove goto line to kill all chrome processes.
Upvotes: 1