How do you kill a service which is stuck ‘starting’ or ‘stopping’

I’ve once again been asked how do you kill a service in Windows NT/2000/XP/2003 which appears to have hung whilst stopping or starting. You may have realised that you can’t kill the process from your standard TaskMgr session.
This is very common whilst developing a service and the official answer is to either: Restart the machine or run the service as your own user account.
If you choose the latter you can then kill the service using your own task manager.

However, if you really need to run the service as Local System or the service was already set to that and you can’t restart the machine there is a work-around. I can’t remember where I learnt this one and so I can’t credit the author – I have been using this for at least 5years though.

Here goes:
Open a command prompt ( if you don’t know how you shouldn’t be reading this!). Do “at 14:05 /INTER taskmgr”, where 14:05 is a time immediately in the future e.g. Now()+1minute.

What is this doing? Well it’s using the “Task Scheduler” service to schedule a Task Manager process to start in 1 minutes time to run interactively.
Why is this any use? The scheduling service runs as “Local System” and so any process it spawns also runs as Local System. Local System can kill any other Local System process – hence it can kill your Hung service.
When the TaskMgr window pops up it’s not easy to tell that it’s a ‘special’ one, thus I’d recommend closing all task manager windows before you schedule the command.

12 responses to “How do you kill a service which is stuck ‘starting’ or ‘stopping’

  1. Hi,, I tried the INTER command and when the task manager opened it and i tried to terminate the process it said: “The operation could not be completed: A Device attached to the system is not functioning”

  2. I tried this, but it does not work trough remote desktop connection. (ie the taskmanager start, but in wrong (i assume local) session.

  3. Cojote, you can this works over remote desktop connection by connecting to the servers’ console session:

    Start > Run > ‘mstsc /v /console’

  4. Cojote, you can make this work over remote desktop connection by connecting to the servers’ console session:

    Start > Run > ‘mstsc /v SERVERNAME /console’

  5. Thanks a lot for the info !!
    It helped me out greatly when I once struggled at work !!

  6. Nice Tip.
    Note that if you enter a time in the past, then this “one time” job remains in the Windows scheduler window. Then you just open windows scheduler and rightclick the job to run it.

  7. Thank you,

    It helped me out greatly,

  8. Services are not usually visible in the task manager.
    Microsofts process monitor allows you to see and kill the process.

  9. Somehow it didn’t work for me but accidently i found this alternative:
    1. CTRL+ALT+DEL (open task manager)
    2. Go to tab SERVICES, right-click on the hang service > Go to Process
    3. Task manager will open PROCESSES tab and highlight the process. Simply right-click > End process tree

  10. Does not work in Windows 7, Says due to security enhancements it will not run in interactive mode. Why not just use “sc queryex servicename ” and get the PID from that, and enter it in “taskkill /f /pid [PID] “? This works on all current windows versions I think,

  11. Thanks @doug, that worked dandy.

  12. @coisox
    Your solution, my friend, kicks butt!
    Thank u!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s