Partager via


TaskList, TaskKill, Remote Machine, Spinning Process, and killing that runaway process! 2-steps!

I’ve been dealing with a “application” these days that is absolutely driving me nuts.  In short, this application that runs in user-mode context and displays data on the screen while locking the keyboard makes for a difficult situation when said application decides to “hang.”  Until the company who writes this dashboard application provides a solution, or until I give up on it altogether, I’ve had to figure out a way to get the machine back to working order where I could control it again.  I thought it might be useful to share what I did as it might just save someone out there who might experience a similar issue – you can decided if this is useful or not.

We are running the Team Foundation Server (TFS) Work Item Manager on a couple of machines that are used for display purposes. These machines run connected to larger televisions and display how our team is doing on our key projects. For more information, see the following post that shares some details. Telerik recently released a Beta 4 (this product has been in a Google-like beta period!) and it now supports Visual Studio SCRUM 1.0. Because we are running a couple of projects on SCRUM 1.0, we went ahead and upgraded the machines. Oops…

The Project Dashboard now gets in a never-ending circle anytime you attempt to get access to the configuration (we store our configuration in source control to share settings – much easier) and looks something like this -

image

Because this machine has no keyboard & mouse (yes, we could add one but that is painful), it makes it particularly difficult when we are RDP'ing to the machine and it hangs. This is where I learned this trick…

Discovering Process ID for the Runaway Application

The first thing I wanted to see if I could do remotely was to determine the Process Id (PID) on the remote machine.  I was able to do this using native Windows 7 (or Server 2008 R2) tools and here are the steps.

  1. Open a command prompt
  2. Type tasklist /? to see a list of available commandsimage
  3. Type tasklist /s {remote computer name} /u {domain | username} /p {password}
  4. This should return a list of running processes on the remote machine – take note of the PIDimage

After you have the PID, you can now utilize another tool to actually force the process to shut down

Effectively shutting down the Application remotely

The next step is to shutdown the process remotely.  This is easily available in-box using the taskkill.exe command that in Windows 7 & Server 2008 R2.  The steps to shut the runaway process are outlined below.

NOTE:  For demonstration purposes, I’ve started Notepad in a user session on a remote server and that session is Notepad.exe

image

  1. Open a command prompt
  2. Type taskkill /? to see the available optionsimage
  3. To stop the remote process, type taskkill /s {remote pc} /u {domain | username} /p {password} /PID {process id}

image

This should return, if it works, a message stating “Success:  The process with PID {PID} has been terminated.  This is it.  This is all you have to do to get this mis-behaving process out of the picture! 

Summary

In today’s post, I just went off the normal path of my typical post and shared a newly discovered “trick” that makes my life a bit easier when I have a remote machine who I can’t access because the “screen” is locked.  This might be a unique scenario and if so then please accept apologies for taking up space on the internet – but I felt the need to put it together since I couldn’t really easily locate other posts relating to it.

Enjoy!

Thanks,

-Chris

Comments

  • Anonymous
    May 12, 2014
    Very useful trick that I didn't know yet. Just helped me alot!
  • Anonymous
    May 31, 2014
    Excelent trick
  • Anonymous
    June 09, 2014
    The comment has been removed
  • Anonymous
    July 30, 2014
    thankyou
  • Anonymous
    October 22, 2014
    nice one
  • Anonymous
    November 11, 2014
    Thanks.. Worked like a charm!
  • Anonymous
    December 09, 2014
    I was killed the my process through cmd ,but still it is available in tasklist
  • Anonymous
    December 11, 2014
    Very useful, thanks for posting
  • Anonymous
    January 14, 2015
    Brilliant
  • Anonymous
    January 20, 2015
    Very useful, thanks for posting.
  • Anonymous
    February 12, 2015
    just had this happen to me, and this got me running in 30 minutes or less.Excellent tip thank you.
  • Anonymous
    March 16, 2015
    Thanks a Ton! You saved my day!
  • Anonymous
    October 05, 2015
    Thanks It works very well........which saves my time ..... :)
  • Anonymous
    October 10, 2015
    I had tried as you given but when i use command TASKLIST /s IP_ADDRESS it runs for a few time and giving error as "RPC server is unavailable". I uses windows 8. What can i do to resolve this problem???
  • Anonymous
    October 10, 2015
    sir i have trued this but it gives me error "RPC server is unavailable". what can i do to resolve it?