The specified service has been marked for deletion

Before upgrading or uninstalling a program, it’s generally a good idea to stop it’s services before doing so.

So i did that using services.msc, and run the uninstaller. However, the installer said that he was unable to remove the service, and a reboot was required. I didn’t really feel like rebooting, i had a look at the registry. The service was still there, and it was still visible in services.msc, but i was unable to start it – the error message said “The specified service has been marked for deletion”.

I tried “sc delete name“, but i got the same error message: “The specified service has been marked for deletion”.

After that, i closed the services.msc window. Now, the service was no longer installed, and after restarting services.msc, it was no longer visible. I ran the installer again, with services.msc closed – it was now able to finish installing the application and it’s associated services.

So what did i learn?

Always close services.msc when installing or upgrading programs!

70 Comments

  1. Drac:

    Thanks for this… you were one of the top matches in google!

  2. Liam:

    Agree with Drac – one of the top, and it resolved my issue, thanks!

  3. Venu:

    Excellent tip, this addressed my problem. Thanks a lot.

  4. nick:

    had a similar problem, and found that logging off and back on did something to fix it.

  5. Richard:

    Good tip. Interestingly, I found that in Windows XP I did not need to close services.msc when reinstalling a service. But on Windows 2000 server I did. So the behaviour is not consistent between different versions of Windows.

  6. Rob:

    I had a disabled service that was marked for deletion. I didn’t want to reboot, shutting down services.msc allowed SCM to continue with the removal, result! Thanks.

  7. Tobias:

    Thanx a lot! I wouldn’t have tried it without your tip :)

  8. Jim:

    Easy fix. Thanks! (Why doesn’t Microsoft publish this type of information?)

  9. Jim #2:

    Thanks a million for this. You just saved me a huge headache and a lot of time :)

  10. Jayce:

    Every once in a while, simply closing .msc doesn’t work for me, and I’m forced to reboot XP in order to get the error to go away, like it says here: http://support.microsoft.com/kb/823942.

    Does anyone know what the underlying issue is? I read something somewhere about a registry entry that can’t be written to – which one?

  11. peter adriaenssens:

    Thanks a lot. very strange

  12. Simon Gadsby:

    Nice find.

  13. Deepthi:

    I guess I figured out the underlying issue.
    The issue occurs when the service is attempted to delete and the instance(s) of the service is still running or is locked by any other programs.
    I used process explorer to figure out the proccesses that had lock on the service instance that has been marked for deletion. Once they are killed, I logged off and logged back in just to find that the issue is resolved! :)

  14. Julian Dixon:

    Had this issue time and time again. Always just rebooted. Now on a production server so needed to clear this without reboot. Use sc.exe to delete service. If it hangs/marked for deletion, check the task manager for any exe’s relating to that services and [End process] them. Finally go to registry, look in HKLM\SYSTEM\CurrentControlSet\Services for the entry relating to the service remove that. AND then the clever part which stumped me until reading your tip was close the services.msc, until I did this it was still marked for deletion. Thanks!

  15. Etienne:

    Lol. Thanks for the tip. And thanks for Google.

  16. Dan:

    Thank you so much! This has been a life-saver!

  17. AC:

    Thank you! Almost did a reboot on msdn article and thought what the heck, I will keep looking.

  18. Bembeng Arifin:

    Thanks so much, this KB (http://support.microsoft.com/kb/823942) indeed does not apply for my windows 2000 PC, after i closed the computer management screen, i can register and unregister many times without problems ;)

  19. lecedre:

    Hi,

    I have seen that it occurs if you try to uninstall a service which is selected when you remove it. Try to unselect the service prior uninstalling.

  20. Scott:

    Thanks for posting this. I didn’t want to restart either!

  21. bogdan:

    hahahahahahha! one of the best tips ever
    i banged my head to the desk for two days now. almost rewritten an entire reinstall procedure with starting/stopping/sc-deleting my service, etc
    AWESOME!

  22. gkokmdam:

    Just the thing to same me time. Thanks. Just marvelous!

  23. MrRobot:

    Thanks, this must be included in an MS kb article! This time it was not easy to just restart, as I’m on a debug session and there are tons of stuff running..

  24. Dave:

    Amazing how simple things are to fix sometimes, but yet we continue to make it harder than it is.

    Thanks so much for saving my day.

  25. William:

    Thanks for the quick fix. LOL I had my services.msc open as well

  26. Alex B:

    Nice, thank you.

  27. Mark Troffaes:

    Thanks for posting this.

  28. Jonathan:

    Thanks for the tip! (pretty obvious if you think it afterwards;))

  29. Yaniv:

    Excellent tip

    helped me too

  30. Ritchie Rich:

    Wonderful explanation about services. However Does the same apply for Kernel Services too?? Has anybuddy come across to get the Kernal Service installed/Uninstalled with out rebooting the computer??

    Alternatively, I am not using “Services.msc” to stop / delete services, I’m doing so on command prompt. But still the kernal service doesn’t get stopped or deleted. I Also observed that there is “Services.exe” running in taskbar which couldn’t be killed (End Task) as it is running in System Context.

    Is there any way around to deal with Kernal Services ??

  31. Victor:

    As an amature at this, I asked everyone that knew something for answers as well as Microsoft. My problem was the fax services, and finally out of desparation I unticked all the blocks on XP windows components, got the result required, and put each back cautiously one by one. Apparently my problem started after a virus attack.
    Your insight helped me to get this right – Thanx a million

  32. Prasanna:

    Worked for me too .. i just closed all SERVICES and tried again , and it worked

  33. George Loughton:

    Lukas,
    Your post has solved my problem, thank you. Generally I don’t need to do this when reinstalling the service, but this time I screwed the password up and Services went into the self-defence mode.
    George

  34. Igor:

    You just saved me a lot of time…

  35. Srikrishna:

    Thanks a lot….Really,Superb tip …Thankyou

  36. Paul Smith:

    Bump!

    Great post. I’d installed & uninstalled the same service a couple dozen times with no issues — stopping it in services.msc, then running installutil & deleting, then refreshing the mmc — and just one of those times it decided to hit me with that “marked for deletion” message. Now I’ll know to close & relaunch the mmc as a *first* resort, instead of diving into HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ to delete the key (as you probably know, that doesn’t work if the MMC is hanging on to an orphaned instance of the service entry).

    Thanks!

  37. Brendan:

    Thanks! This just saved me some trouble. Lukas Beeler for president.

  38. Shanthi:

    Thanks a lot for the info.. Before I found this site, I used to restart my machine every time… Now I escaped from a big problem.
    Thanks again..

  39. GroverBot:

    THANKS! I always rebooted, didnt realize it was a stupid windows that needed to be closed.

  40. Deepak:

    Thanks a lot…
    it save lots of time as everytime i dont need to reboot the server..

  41. Uma:

    Hi, Thx a lot for giving such a useful tip :)

  42. aecsant:

    well said Deepthi,

    i was stuck too, but when i killed the process associated with the service, and restarted service.msc, it gone.

    saved lot of time.

    Thanks OP

  43. Dhilish:

    Fantastic. It saved time

  44. Carlos:

    Thanks a lot man!!!

    This was very useful for me!

  45. Eric:

    Thanks – very helpful… This “feature” still exists in Win7 x64!

  46. Musafir_86:

    -Thanks a lot! Even though my problem is different, I learnt the “SC” command from you!

    -BTW, my problem is WinPhlash crashed during updating Acer Aspire 4520 BIOS. Retrying brought up a message saying NTPHLASH.SYS marked for deletion (error 1072).

    -So, I run the WinPhlash program on another laptop, import (and edit accordingly) the HKLM\System\CurrentControlSet\Services\Winphlash and HKLM\System\CurrentControlSet\Enum\Root\Legacy_Winphlash keys (NOTE: permission need to be set in Regedit first). The I used “SC STOP WINPHLASH” to stop the currently loaded/running NTPHLASH.SYS. Then, I retry to flash the BIOS again and succeeded! Alhamdulillah. :)

    Regards,
    -Musafir_86.

  47. George Vangelis:

    Thanks for the help.
    I had the same problem with Musafir_86.
    I tried to Winphlash my Acer Aspire One AO751h with the latest bios and it always came up with an error message that I am not an Administrator…
    I then used “SC STOP WINPHLASH” without any other modifications and it worked like a charm!

    Regards,
    George

  48. Shullz Mkwelo:

    Amazing…. Thanks, so simple and its all I needed after 2 hours of googling

  49. jorge:

    Excellent! I wonder if i should close MSC.exe as part of my uninstall :)

  50. Nikolodeon:

    Excellent! clear and simple, thanks a lot

  51. Kshitij:

    Amazing that even after 2 years, this post saved my hours at mid night. I was strugling to figure out how to get those services out, while installation was on. Thanks a ton!

  52. Ana:

    This helped me also :). I would have never thought that this is the problem. Thank you.

  53. DikShuttle:

    I had the error with only the networks window open. Closed the window… error went with it. Yaaay.

    (I was un- & re-installing File & Printer Sharing in XP2SP2)

  54. Gareth:

    Thanks I would not have figured out such a stupid problem my self. :-)

  55. josepherdon:

    thanks.
    a great help.
    I thought there was something I am missing in my .NET Windows Service project.

    Kudos!

  56. LatinSuD:

    From this behaviour it looks like services.msc is holding a kind of lock on services.
    This contrasts with the fact that you have to press F5 to update the service list when it changes.
    Weird.

  57. khushboo Patel:

    Thanks. You have solved my critical problem….

  58. Pavan:

    Thanks. It worked well for me…

  59. hdrockerroller:

    The reason this is so is that service.mcs holds open handles to the service being deleted.

    From Msdn:
    The DeleteService function marks a service for deletion from the service control manager database. The database entry is not removed until all open handles to the service have been closed by calls to the CloseServiceHandle function, and the service is not running. A running service is stopped by a call to the ControlService function with the SERVICE_CONTROL_STOP control code. If the service cannot be stopped, the database entry is removed when the system is restarted.

    The service control manager deletes the service by deleting the service key and its subkeys from the registry.

    Hope that helps

  60. Jai:

    Great!
    Thanks,
    I even ran “sc delete servivename” but kept my service.msc open to see if the services are getting deleted. But it was not. I searched and found your site. It was interesting to note that all what I had to do was just close services.msc

    Jai

  61. atconway:

    Nice, did the trick! Didnl;t happen all of the time; normally I keep the services window open when uninstalling and then reinstalling, but this time closing and re-opening the window worked. Thank you.

  62. Cristi:

    Good one!

  63. indie-kick:

    Great advice , I had services open, closed services down, re-opened services and the mark for deletion was gone.

    Then installed remote agent and all working

    Good advice – thank you

  64. iVKO:

    Thanks !!!

  65. Suresh:

    it too worked for me.. thank you

  66. Mahesh R. Kulkarni:

    Thanks man….this information helped me lot.
    I deleted the service using sc delete command but still it was showing in Services.msc as disabled. I was fade up of this thing.Refreshed lots of time.
    But this article gave me hint for restarting services.msc.

  67. tytusse:

    Damn, so no restart needed :)
    Thanks!

  68. David:

    It’s still good tip even on Windows Server 2008 R2 64 bit! Tnx.

  69. lyd:

    thanks! closing Services window and reopening fixed the issue :)

  70. Mukul:

    Thanks a lot ! saved me a lot of headache

Leave a comment