Execute Windows command prompt output to get PID
1 answer
@echo off
for /f "tokens=5" %%a in ('
netstat -noa -p tcp ^| find /i "CLOSE_WAIT"
') do if not "%%a"=="0" echo taskkill /pid %%a
Use the command for
to split the line using spaces as delimiters, get the 5th token in the line, and if there is a PID, kill the process
Commands are taskkill
displayed only on the console. If the output is correct, remove the commandecho
+4
source to share