Windows Services, services.msc and the "This Service is marked for deletion" error.
In my current project, we have a windows service that we are developing and debugging, which involves a lot of installing/uninstalling the service. One common problem when uninstalling a service is that while the uninstallation is successful, you still see the service listed in the Services console(services.msc). If you try to start it, stop it or uninstall it again (using installutil.exe or sc delete) you get an uninformative "This service has been marked for deletion".
The KB article about this problem suggests you restart the computer, which is pretty much overkill. Sure, it'll work, but you'll never find out what caused it in the first place. Turns out it's a pretty simple affair: just make sure you close the Services console, which apparently holds a handle of some sort to it. You don't have to do it before you uninstall. The minute you close the console, all services marked for deletion will be deleted, and all will be well.
When doing it on a server, it's important to make sure you've closed all Services consoles on all active sessions. I've seen this error happen when no console was open, and it was fixed by running Task Manager and killing all instances of mmc.exe. I could have logged on to the other sessions and closed it gracefully, but I was lazy. Did the trick.
33 Comments
Comments have been disabled for this content.
THANK YOU! said
This was driving me crazy. I am working on a service and have to uninstall/reinstall it repeatedly, but sometimes I accidentally uninstall twice in a row and this happens. Hurray for internet search :)
martin r davissr said
the window service.msc for deletion error pleae rover this my desk top I RUN windows XP ON MY DESKTOP
rpgivpgmr said
Thank you Avner. Looks like Microsoft Needs You!
Justin said
Just what I needed to know!
Salman said
what r the services that run when MOM is running.
ctupper said
Thanks much!!! I hate rebooting.
KVK Consultancy said
Good Article. Know exactly how you felt.
Very Greatfull!!!!! said
Thank you! Some shameless plugs: without reboot delete services without reboot nt services wont remove windows services wont remove "This Service is marked for deletion"
Colby said
THANK YOU VERY MUCH
Anand Muddi said
Thanks!! This really helped.
kaushalparik27 said
Thanks!! This really helped.
PeterBrunone said
Wow. I can't believe I had to google for a blog post to get an answer for this. Thank you for writing this up so I didn't have to keep restarting my computer all night.
Rohonesh Kar said
Thanks so much for this.. this restarting or logging off the system was driving me crazy.. Actually felt foolish on realizing that the solution was so simple..
Ajay Kewale said
That's what I wanted..Thanks!!!
yayai said
OMG me life saver!
Miahoo said
Man, ty!! it just drive me crazy! and such a simple solution. i LOL`ed!
ruben ruvalcaba said
Wow! you're the man
Wilson Edgar said
I'll just add another (and much deserved) Thank you.
Nic said
Unable to start http using net start http Driver is blocked
Charles said
Genius I had been staring at that stupid service for an hour should have known to close and open the window Cheers
cn_kevin said
I find no active sessions, no instances of mmc.exe. but it doesn't work well. so I'am delete it twice,.
remo said
Thanks! google + you = FTW
Chris said
Thanks man, helped me too!
Neleus said
I was uninstalling MySQL server and faced with the same problem. I killed all mmc processes and then reopened Services to see how it helped but the service was there still. I guessed that msiexec process could also hold that service. And after restarting uninstall it helped. Thanks!
weblogs.asp.net said
Windows services services msc and the quot this service is marked for deletion quot error.. Awful :)
b_man said
Thanks! This got me pointed in the right direction, but it wasn't any MMC causing my grief -- It seems that Process Explorer from SysInternals/MS can also keep open handles to services.
Tommy said
Thx, solved another similar problem for me!
Fred said
I confirm that also Process Explorer from Sysinternals seems to keep some handles. Closing that the solution works fine! bye and thank you Valerio
Nah said
Simple and brilliant. Thanks
Bunnynut said
This really cracked me up. I have had this problem for a couple of times and decided to restart the develop server (I should apply for a job at MS), which works obviously. I cant believe the solution is this simple, thanks for posting this.
B Jansen said
Thanks, this saved me a lot of reboots!
Gabrielle said
brillant. this just saved me.
Waldo said
Thanks Man, this helped a lot