Thursday, August 30, 2012

Kill a Process in Windows

Dear friends,
This time I am writing a common article, how to kill a process which is running
on a port in Windows machine.
 
In Unix it is quite easier by using below commands:

ps -eaf | grep PROCESS_NAME
kill -9 PROCESS_ID (returned from above command)

But in Windows it is quite strange, see below:


D:\Sandbox\jboss-4.2.3.GA\bin>netstat -o -n -a | findstr 9092
  TCP    0.0.0.0:9092           0.0.0.0:0              LISTENING       7620
  TCP    127.0.0.1:9092         127.0.0.1:53616        ESTABLISHED     7620
  TCP    127.0.0.1:53616        127.0.0.1:9092         ESTABLISHED     7620
  TCP    [::]:9092              [::]:0                 LISTENING       7620

D:\Sandbox\jboss-4.2.3.GA\bin>taskkill /F /PID 7620
SUCCESS: The process with PID 7620 has been terminated.

D:\Sandbox\jboss-4.2.3.GA\bin>