Remove Windows service from command line

27

7

I would like to do this because I have a half installed service because of installation failure which is just there, non-functioning.

How can I delete the Windows service using the command line?

Anil Namde

Posted 2010-04-28T10:56:25.547

Reputation: 391

Related post - How can I delete a service in Windows?

– RBT – 2018-06-21T08:14:32.030

Answers

36

NOTE: You'll likely need an elevated command prompt (right click => "Run as Administrator") to execute this command

the sc command is what you want, specifically sc delete

C:\Users\Jeff>sc delete
DESCRIPTION:
        Deletes a service entry from the registry.
        If the service is running, or another process has an
        open handle to the service, the service is simply marked
        for deletion.
USAGE:
        sc  delete [service name]

Jeff Atwood

Posted 2010-04-28T10:56:25.547

Reputation: 22 108

9If you're in powershell, you'll want to make sure to type sc.exe because sc in powershell gets you the Set-Content cmdlet which will quietly look like it might have worked. – Andrew – 2015-09-09T16:00:51.470

13

We need to stop the service before deleting it from the Registry:

sc stop [Service name]  
sc delete [service name]  

Run Command prompt as an administrator and execute above commands.

Enclose the service name in double quotes if it contains spaces.

CSharp

Posted 2010-04-28T10:56:25.547

Reputation: 231

1Just as an fyi, sc stop might not be finished stopping when sc delete runs, which can cause problems. It's not a common problem, but some services take a while to wind down. I'm not sure if I've run into this problem at straight commandline, but I definitely have when invoking service removal APIs for a couple a languages. – kayleeFrye_onDeck – 2017-01-21T00:27:48.730

-1

Simply put quotation marks between any service name that contain spaces C:\WINDOWS\system32>sc delete "Your Ugly Service"

Ahmed Adel

Posted 2010-04-28T10:56:25.547

Reputation: 1

It would have been better to suggest an edit to one of the existing answers to include the helpful information about double-quoting service names with spaces. – I say Reinstate Monica – 2018-05-16T02:33:43.320