Computer Tips and Tricks
Get the latest posts via rss

Tuesday 22 December 2009

Killing a hanging Windows Service

Services have the tendency to hang during a "Starting" or "Stopping" state causing a program to fail. Usually a reboot can correct the problem, but this is not always appropriate. There is an alternative in the form of an "sc query" and a "taskkill" commands.

The "sc query" is used to identify the PID or process identifier of a running service. This is required to perform the "taskkill" command.

To obtain the PID, first find out the exact name of the service you wish to kill. It can be found in the service properties.

Remember this name is case sensitive and must be copied exactly.
  • Now load a command prompt with admin rights
  • Type the command "sc queryex [nameofservice]"

The second line from the bottom gives you the PID number of that service. Now to "kill" the task and reset it to a "Stopped" state.

Use the command "taskkill /PID [PID Number from your sc query] /F" (The /F is a force command needed to force the process kill.

The service should now be in a "Stopped" state.

4 comments:

Anonymous said...

Thaaaank you :)

Anonymous said...

I am logged in as admin and I right clicked opend CMD as administrator and still received "Access is Denied"

Anonymous said...

thank you

Anonymous said...

youhou!!!saved me!!!

Post a Comment