/* ]]> */
Feb 012010
 

This is very handy if you have a hung (non-responsive) process that you need to terminate.

The Old Way

Using conventional methods, you might pull up Windows Task Manager, identify your hung process in the long list of Image Names within the “Processes” tab, right-click the process and select “End Process”. From there you might have to wait quite a while for Windows to actually do the termination.

The PowerShell Way

The PowerShell method is much quicker especially if you know the name of the process to be terminated. There are two steps involved: (1) identify the process ID(s) of program to be terminated and (2) stop the running process(es). The associated PowerShell cmdlets are “Get-Process” and “Stop-Process” (or their convenient Unix-Shell aliases “ps” and “kill”.

Example

For this example, let’s say that your Internet Explorer web browser has become unresponsive and you need to terminate it (not that that would ever happen in real life). Here are our two steps in action:

(1) Identify the process(es) using Get-Process (or in this case I will use the shorter alias “ps”). This is very easy if you know at least part of the process name that you’re looking for. In this case, I happen to know that the process name for Internet Explorer is “iexplore”. For this example, I’ll just find all processes that start with “iex” as follows:

(2) We can see that there are two processes associated with Internet Explorer – I want to stop them both. This is done using the Stop-Process cmdlet (or in this case I will use the shorter alias “kill”).

That’s all there is to it – the processes are killed and I can now restart Internet Explorer.

 

 Posted by at 8:58 am

  One Response to “Kill a hung process with PowerShell”

  1. Also, these will work:

    ps iex* | kill

    or

    kill -name ie*

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Page optimized by WP Minify WordPress Plugin