How To Uninstall a Failed Windows Service Installation
August 16th, 2007
I’ve been doing a lot of work with Windows Services in VB.NET recently and, as a result, I’ve ran into a number of little tricks and traps in this area. I’m going to post these short, hopefully helpful, tips as I come across them.
One of these traps can happen when a service gets installed but gets stuck where you can’t completely uninstall it or install a new version. This can be caused by errors in your code, errors on the install itself, copying over an incorrect DLL or EXE manually, or other such things. When this happens it can be quite frustrating.
Here’s what you’ll see if you encounter this problem. When you try to reinstall the service, you’ll get a dialog that says, “The specified service already exists”, even if you’ve gone through the uninstall either from within Visual Studio or from the Add/Remove Programs control panel applet.

The program’s executables have been deleted from the installation folder but you’ll see your service app in the Computer Management Service console. You can’t seem to get rid of it. If you try to uninstall, you’ll see this message saying you can’t do it.

I’ve seen forum posts where people resorted to renaming their service after encountering this error. Some manually edited their registry to get rid of it. Still others wrote a quickie program or script using WMI to kill it. But, there is a much easier way to deal with it.
There is a command line utility in Windows called SC, short for service controller, that allows you to control Windows Services manually. One of the available commands is “delete”. This command deletes references to the specified service in the registry. Here’s the command syntax:
sc delete NameOfYourBadServiceGoesHere
Once you run this from the command window, the failed installation is cleared from the registry and you’re ready to do a clean install of your service program. Of course, you need to be careful about using this command in production environments. Also, you should have gone through the uninstall process first to remove the executables before executing this command.
Let me know if you found this tip helpful or if you have any other ideas or questions about it by leaving me a comment.
Entry Filed under: Tip Sheets
Rate This Article:









(7 votes, average: 4.86 out of 5)
11 Comments Add your own
1. Hans Kappert | April 8th, 2008 at 6:24 am
This was utterly helpful. I searched the registry for all that had to do with the service and deleted it. I still got the message. With this trick, I can continue my work. Thanks again.
2. karuna | April 16th, 2008 at 11:20 pm
Hi
I am able to delete my service from Service list and registry but it still shows in Add/Remove programs under control panel. Even I have restarted my machine also.
Please help me out.
Thanks
Karuna
3. karuna | April 16th, 2008 at 11:22 pm
Hi
I have tried SC delete command line tool also.It gives an error :
Open service failed 1060..
Thanks
Karuna
4. James Collett | April 25th, 2008 at 4:36 am
This utility saves me time so it is reall6y useful.
I am still in the dark as to why the beginner’s textbook service I created will not uninstall from the VS 2005 IDE.
Is this just Microsoft being crap?
5. Mike | May 27th, 2008 at 2:29 pm
After 4 hours of googling and trial and A LOT of error, I finally found this article and it worked like a charm! I HATE TECHNOLOGY!! :)
6. Scott Klueppel | June 16th, 2008 at 10:55 am
Excellent!!! I have installed and uninstalled my service countless times, and never had an issue until today. None of the other fixes worked. Thank you.
7. Sach | July 9th, 2008 at 4:17 pm
What happens if the sc command is run before the uninstall of exe files?
Thanks
8. Brad | September 8th, 2008 at 11:09 pm
Thanks for posting this, saved me another headache
9. vu.dao | October 21st, 2008 at 2:01 am
Excellent! Thanks.
10. Ak | November 10th, 2008 at 1:48 pm
Great post. Saved me a lot of pain in trying to work the registry to delete a ghost service. Thanks.
11. Paul | November 25th, 2008 at 5:11 pm
I was so frustrated… thx a lot.
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed