Stopping a Hung Windows Service without Rebooting

Every Windows system manager has tried to stop a service and had it hang in a STOP_PENDING state and received the dreaded “Service did not respond to shutdown request” dialog box.  And you can bet that Murphy makes sure this happens when there is NO way you can reboot the server.

Recently while developing a Windows Service for a client, I had a version of the service hang.  I did some searches and found what has been a fairly reliable procedure for “unsticking” hung services.

First, type in the following command:

C:\bin>sc queryex "Some Service"

SERVICE_NAME: Some Service 
        TYPE : 10 WIN32_OWN_PROCESS 
        STATE : 3 STOP_PENDING 
                  (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) 
        WIN32_EXIT_CODE : 0 (0x0) 
        SERVICE_EXIT_CODE : 0 (0x0) 
        CHECKPOINT : 0x0 
        WAIT_HINT : 0x0 
        PID : 5576 
        FLAGS :

Next, get the PID (process ID) from the output and use it in the following command:

C:\bin>taskkill /f /pid 5576

This will forcibly terminate the service’s process and you should then be able to move forward with diagnosing the issue and/or replacing the code or possibly updating the configuration and restarting the service.

avatar
About Sam (12 Articles)
IT professional and entrepreneur with over 30 years of computer experience. He is a Founder and the Chief Engineer for Tech Savvy Leads, the makers of TSL Ping Tree. In addition to his role at Tech Savvy Leads, he provides senior level technology consulting services.

1 Comment on Stopping a Hung Windows Service without Rebooting

  1. Thanks for the info!

Leave a comment

Your email address will not be published.


*