I am using the following script to kill a process in CLOSE_WAIT state that listens to a certain ip and to a certain port.
FOR /F "tokens=5 delims= " %%I IN (
'netstat -ano ^| find "127.0.0.1:5900" ^| find "CLOSE_WAIT"'
) DO (
taskkill /PID %%I
)
The script does it's job but I am looking for a small modification.
I would like the process to be killed only if there are more than 10 connections into CLOSE_WAIT state. If let's say there are only 3 connections in CLOSE_WAIT then the process shouldn't be killed.