Tuesday, June 23, 2009

Closing a port / killing a process using WMIC

This is really just for my memory's sake. I'm writing this up as I've just recently had to perform these steps a couple of times. For 99% of the readers, this is old hat. Here's the situation:

You have a port that's open and you want it closed, or, you have a process running that you can not kill. Here are the steps I've followed:

netstat -naob (use on XP Pro or newer...I don't think the 'b' switch is available in the home edition.)
Find the port that's open or the offending process.

wmic process list brief
This will list the process and their processid.

wmid process [processid] delete.

Poof....it's gone.

WMIC...hugely powerful. I've mentioned it in posts here and here.

1 comment:

  1. My favorite variety for this command is :

    wmic process where name="firefox.exe" call terminate

    Its easy to script using this method.