Killing a Windows Service that seems to hang on “Stopping”

When a service hangs in a “Stopping” state, a SysAdmin can kill the service using this procedure:

  1. Open a command-prompt, in Administrator Mode, and query the service (e.g. the BITS service)
    sc queryex BITS
  2. This will give you the following information:

NOTE: In the STATE field, it should mention stopping.

  1. In the sc queryex results you can find the process identifier (PID). With it, you can kill the associated process either by using the task manager or by using taskkill:

taskkill /PID 420 /F

The /F flag is needed to force the process kill.

Another way to go about it is to identify the Displayname of the service, using the services console   (services.msc):

and use:

taskkill /IM “Displayname” /F

This is very useful for emergencies but you shouldn’t use it on a regular basis (use it as a last chance to solve the problem or to avoid the need of a reboot in an exceptional situation).

More info on sc.exe can be found via http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx.