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 -
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.
- Open a command prompt
- Type tasklist /? to see a list of available commands
- Type tasklist /s {remote computer name} /u {domain | username} /p {password}
- This should return a list of running processes on the remote machine – take note of the PID
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
- Open a command prompt
- Type taskkill /? to see the available options
- To stop the remote process, type taskkill /s {remote pc} /u {domain | username} /p {password} /PID {process id}
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