Monday, March 4, 2013

Killing a Windows Service that Seems to be Hanged on Stopping or Starting

Windows Services can sometimes stuck in the stopping or starting state. I have faced this issue with IBM Datacap Server services in development environment.  Rebooting workstation clears the problem. But following can be done to kill  hanged service and avoid reboot workstation or server.


  • Get the Service Name. Go to Services(Run--> services.msc)
       


  • Find out the Process ID using sc queryex on the Windows Service.
                    C:\Users\Admin>sc queryex DCTMS
    SERVICE_NAME: DCTMS
                    TYPE                  : 10  WIN32_OWN_PROCESS
                    STATE               : 3  STOP_PENDING
                                                      (STOPPABLE, PAUSABLE, IGNORES_SHUTDOWN)
                   WIN32_EXIT_CODE      : 0  (0x0)
                   SERVICE_EXIT_CODE  : 0  (0x0)
                   CHECKPOINT        : 0x0
                   WAIT_HINT          : 0x0
                   PID                           : 4716
                   FLAGS                     :
  • The Process ID is 4716.  So now we can issue the taskkill /F command on the process.
         Note: in Windows 2008, if we are not running the command prompt with ‘run as administrator’, we  
         will get an access denied error on the delete.
            
              C:\Users\Admin>taskkill /f /pid 4716
   SUCCESS: The process with PID 4716 has been terminated.

         

No comments:

Post a Comment