Deleting Windows Services that won't uninstall

I created a Windows Service installer using WiX and included a custom action that called PowerShell to run a script.  Unfortunately, I called the script with the wrong parameters and then the service would not uninstall.  So, I tried a lot of different tricks and finally found a recommendation on the web to run the sc.exe command with the delete parameter.  This was the only solution that worked, so I thought I'd share it here.  I executed:

sc delete "My Service Name"

Note that to execute the same command from PowerShell, you must specify the full path to sc.exe because PowerShell has a default alias for sc assigning it to Set-Content.  I executed it as follows:

C:\Windows\System32\sc.exe delete "My Service Name"

I hope this saves someone else some grief in the future.


Comments (5)

  1. Papy Normand says:

    Thanks to share this information.

    I have used it 5 years ago, but i have forgotten this article fully. Now , it is in my favorites. Ouf !!

    For your 1st post, it is a success.

    I hope you will go on to be clear, and easy to understand.

  2. Papy,

    Thanks for the positive review!  I will do my best to keep writing well and clearly.


  3. Jesse MacNett says:

    Just bailed me out of a major PITA for a service that kept throwing an exception during a installutil -u run.  Many thanks.

    - Jesse

  4. Debashis Karmakar says:

    Thanks Robert .. this is awesome.. your suggestion works like a charm,,

  5. Sheila says:

    Thank you ! Successful in allowing me to UNDO and REDO my Window 2012 Service set up !

Skip to main content