Freigeben über


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.

Rob

Comments

  • Anonymous
    June 09, 2012
    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.

  • Anonymous
    June 27, 2012
    Papy, Thanks for the positive review!  I will do my best to keep writing well and clearly. Rob

  • Anonymous
    October 08, 2012
    Just bailed me out of a major PITA for a service that kept throwing an exception during a installutil -u run.  Many thanks.

  • Jesse
  • Anonymous
    September 29, 2015
    Thanks Robert .. this is awesome.. your suggestion works like a charm,,

  • Anonymous
    April 25, 2016
    Thank you ! Successful in allowing me to UNDO and REDO my Window 2012 Service set up !