173

How do I uninstall a Windows Service when there is no executable for it left on the system? I can not run installutil -u since there is not executable left on the system. I can still see an entry for the service in the Services console.

The reason for this state is probably because of a problem in the msi package that does not remove the service correctly, but how do I fix it once the service is in this state?

Magnus Lindhe
  • 6,678
  • 5
  • 43
  • 58
  • 1
    Possible duplicate of [How do I uninstall a Windows service if the files do not exist anymore?](http://stackoverflow.com/questions/197876/how-do-i-uninstall-a-windows-service-if-the-files-do-not-exist-anymore) – Pacerier Apr 11 '16 at 19:03

7 Answers7

337

You should be able to uninstall it using sc.exe (I think it is included in the Windows Resource Kit) by running the following in an "administrator" command prompt:

sc.exe delete <service name>

where <service name> is the name of the service itself as you see it in the service management console, not of the exe.

You can find sc.exe in the System folder and it needs Administrative privileges to run. More information in this Microsoft KB article.

Alternatively, you can directly call the DeleteService() api. That way is a little more complex, since you need to get a handle to the service control manager via OpenSCManager() and so on, but on the other hand it gives you more control over what is happening.

CodeNaked
  • 38,487
  • 6
  • 108
  • 141
Treb
  • 19,065
  • 6
  • 50
  • 83
  • It did exactly what I wanted and removed the service from the registry. It doesn't show up in the Services console any more. Thanks! – Magnus Lindhe Dec 01 '08 at 14:03
  • 1
    I get "Access is denied." What to do next? – Nick Mar 16 '16 at 14:24
  • 6
    Just a note for whoever trying to execute command in Method 1 in PowerShell: sc is not for communicating with service control manager. It is Set-Content command. Use sc.exe instead. – Yasser Sinjab Apr 11 '16 at 08:47
  • 1
    If you get error 1072, make sure you don't have the services control panel open (see [this other question](http://stackoverflow.com/questions/305037/sc-deleteservice-failed-1072)) – Giles Feb 08 '17 at 11:17
  • I was getting the below error. [SC] OpenService FAILED 1060: The specified service does not exist as an installed service. Later tried the same with power shell and it works ! – crazydan Sep 28 '19 at 13:49
25

Remove Windows Service via Registry

Its very easy to remove a service from registry if you know the right path. Here is how I did that:

  1. Run Regedit or Regedt32

  2. Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"

  3. Look for the service that you want delete and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).

Delete Windows Service via Command Window

Alternatively, you can also use command prompt and delete a service using following command:

sc delete

You can also create service by using following command

sc create "MorganTechService" binpath= "C:\Program Files\MorganTechSPace\myservice.exe"

Note: You may have to reboot the system to get the list updated in service manager.

Community
  • 1
  • 1
kombsh
  • 5,078
  • 3
  • 38
  • 42
  • 3
    Is doing it the registry way safe? Is the "final result" of the registry way the same as the "final result" of `sc delete`? – Pacerier Apr 11 '16 at 19:00
  • 5
    No, I just tried deleting a service from regedit directly. As as result, now the the entry of the service I wanted deleted remains in Service, while the Description of it shows: "" – GJ. Aug 22 '16 at 02:53
11

found here

I just tried on windows XP, it worked

local computer: sc \\. delete [service-name]

  Deleting services in Windows Server 2003

  We can use sc.exe in the Windows Server 2003 to control services, create services and delete services. Since some people thought they must directly modify the registry to delete a service, I would like to share how to use sc.exe to delete a service without directly modifying the registry so that decreased the possibility for system failures.

  To delete a service: 

  Click “start“ - “run“, and then enter “cmd“ to open Microsoft Command Console.

  Enter command:

  sc servername delete servicename

  For instance, sc \\dc delete myservice

  (Note: In this example, dc is my Domain Controller Server name, which is not the local machine, myservice is the name of the service I want to delete on the DC server.)

  Below is the official help of all sc functions:

  DESCRIPTION:
    SC is a command line program used for communicating with the
    NT Service Controller and services. 
  USAGE:
          sc
Fredou
  • 18,946
  • 9
  • 53
  • 107
10

Here is the powershell script to delete a service foo

$foo= Get-WmiObject -Class Win32_Service -Filter "Name='foo'"
$foo.delete()
Nima Soroush
  • 9,824
  • 3
  • 46
  • 50
9

My favourite way of doing this is to use Sysinternals Autoruns application. Just select the service and press delete.

Thomas Bratt
  • 40,822
  • 34
  • 113
  • 133
4

I'd use PowerShell for this

Remove-Service -Name "TestService"

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-service

JoeRod
  • 769
  • 7
  • 15
  • 28
  • only available in PS6 – BozoJoe Jan 21 '19 at 17:32
  • I was getting the below error. [SC] OpenService FAILED 1060: The specified service does not exist as an installed service. Later tried sc delete with power shell and it works ! Thanks to the idea of power shell. – crazydan Sep 28 '19 at 13:51
3

Create a copy of executables of same service and paste it on the same path of the existing service and then uninstall.

Samiksha
  • 5,852
  • 6
  • 26
  • 28