Monday, September 2, 2013

CMD to find & kill the process with port Number

Use cmd and type as :
1. C:\>netstat -ano
     It will display the Active Connections with columns (Proto|Local Address|Foreign Address|State|PID)
     

2. To find specific active process :
     C:\>netstat -o -n -a | findstr 127.0.0.1:2020
           TCP    127.0.0.1:2020         0.0.0.0:0              LISTENING       1276
           
           OR
           
     C:\>netstat -ano | find "2020"
           TCP    127.0.0.1:2020         0.0.0.0:0              LISTENING       1276
           

3. To kill the processe in windows OS, use processid (PID) in this below command :
     C:\>taskkill /F /PID 7068
     SUCCESS: The process with PID 7068 has been terminated.


4. If we try to kill the process which does not exist in the active connection list, then
     C:\>taskkill /F /PID 7068
     ERROR: The process "7068" not found.