Friday, December 14, 2012

Windows Hung Service

Today I had an issue where a windows service was stuck in a "starting" state.  Since this was an email server and the service in question was IMAP, doing a reboot wasn't a good option.  So i searched around and found this useful piece of information:

You can force kill an service if you know the services PID.
To get the PID, you can run the following to query the service and output them to a text file to make it easier to search.

  • sc queryex > C:\Running_Services.txt
Once the command completes, use a text editor (Notepad++) to find the service you are looking for.  You will see the Service Name, Display Name, and the PID.  Now that you know the PID, you can issue the following to kill the process.  For our example, lets say the PID is 12345
  • taskkill /PID 12345 /F

Now the process should be terminated, and a restart can be attempted.