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.