589

How do I uninstall a .NET Windows Service, if the service files does not exists anymore?

I installed a .NET Windows Service using InstallUtil. I have since deleted the files but forgot to run

 InstallUtil /u

first. So the service is still listed in the Services MMC.

Do I have to go into the registry? Or is there a better way?

gztomas
  • 2,144
  • 2
  • 21
  • 36
Thomas Jespersen
  • 11,101
  • 12
  • 43
  • 54

14 Answers14

1162

You have at least three options. I have presented them in order of usage preference.

Method 1 - You can use the SC tool (Sc.exe) included in the Resource Kit. (included with Windows 7/8)

Open a Command Prompt and enter

sc delete <service-name>

Tool help snippet follows:

DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services.

delete----------Deletes a service (from the registry).

Method 2 - use delserv

Download and use delserv command line utility. This is a legacy tool developed for Windows 2000. In current Window XP boxes this was superseded by sc described in method 1.

Method 3 - manually delete registry entries (Note that this backfires in Windows 7/8)

Windows services are registered under the following registry key.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Search for the sub-key with the service name under referred key and delete it. (and you might need to restart to remove completely the service from the Services list)

RockScience
  • 15,586
  • 22
  • 74
  • 117
Jorge Ferreira
  • 88,967
  • 24
  • 112
  • 131
  • 23
    Method 3 seems to back-fire on Windows 7. – rmiesen Jul 08 '13 at 02:15
  • 29
    At method 1, you may experience "The specified service does not exist as an installed service" error, although you see the service at the MMC!!! This is because the name you see is the DisplayName. You may lookup the actual service name at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services tree and pass *that* as service-name. – denispyr Jan 30 '14 at 15:41
  • 9
    Method 3 backfired for me too on Windows 7. Service is there now with Description `` – Zugwalt Mar 18 '14 at 16:55
  • 27
    note be careful if you are using powershell with sc - it overrides the application with it's set-content cmdlet and if you run sc delete blah it silently fails – JonnyRaa Mar 21 '14 at 14:37
  • 2
    @Zugwalt try signing out and signing back in again - this solved the "Read Description" error for me, the service was now gone from the service manager window – GrahamMc Apr 11 '14 at 10:47
  • 3
    Remember if you are using Method 1 and your service name has spaces in its name, surround the service name in double quotes. Your windows needs a restart to eliminate the service name from the MMC list. – Ryan May 19 '14 at 04:39
  • @smink How do you do this programmatically? I mean how can I put it in my installer code so that prior to the installation, if any previous instance prevails on that machine, it will be deleted. – Yogesh lele Aug 13 '14 at 12:49
  • 1
    After using Method 1, I had to restart Windows 7 for the service to be deleted. – George Onofrei Aug 14 '14 at 11:25
  • 1
    Method 1 seems to work for me on Win 7 and if you refresh the Services Control Panel the removed service disappears without a reboot. – Jason D Aug 19 '14 at 20:21
  • 6
    Related to "Method 1", an easier way of finding the Service Name than looking in the registry is by displaying the property sheet for the service in the Services application. (Right-click on the service and select "Properties") The Service Name is the first item displayed on the General tab. – donperk Sep 15 '14 at 18:36
  • 1
    Method 3 seems to back-fire on Windows 8 as well. – DmitryBoyko Oct 21 '14 at 10:52
  • 11
    NOTE: You have to restart your computer after doing Method 3! Then look at list of Services; it's probably gone now. If it's still in the list, then just do Method 1 to remove it from that list. – East of Nowhere Oct 24 '14 at 14:59
  • 2
    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
  • @smink, How does it "backfire" in Windows 8? And does it backfire in Windows 8.1? – Pacerier Apr 11 '16 at 19:04
  • 1
    Take an hours of trying "sc delete" It not working in powershell (without warning or error !, it just run and keep silent !). Then I switch to cmd , It works perfectly ! – Hung Doan May 12 '16 at 10:10
  • @hungdoan this is because SC in powershell is Set-Content. You have to use 'CMD SC' in powershell and it will also work. – Luigi Mackenzie C. Brito Oct 27 '16 at 21:21
  • 2
    At method 1, you may experience "The specified service does not exist as an installed service" error, if there is space in service name. Surround it in double quotes to resolve the issue. – Upendra Gughane Dec 28 '16 at 07:04
  • Used method 1 on windows 8.1, putting quotes around the display name didn't work for me, instead I just pulled up the services window by searching for 'Services' and then I right clicked on the service I wanted to remove. In the pop up you'll see 'Service name: wookieeService' and (sometimes) 'Display name: Wookie Rendering Service'. Then typing 'sc delete wookieeService' removed it for me, I had to close and re-open the services window for it to be removed from the list. – letthewookieewin Jun 06 '17 at 16:57
  • Protip for PowerShell users: to invoke a native Windows executable/batch file/whatever instead of a PS command or alias with the same name, simply specifiy the filename **including the extension**. Thus, running `sc` in PowerShell will invoke the `Set-Content` cmdlet, while running `sc.exe` will invoke Windows' Service Control executable. – Ian Kemp Mar 21 '18 at 13:06
  • 1
    If you happen to know only the friendly (display) name of the service, this PowerShell oneliner will nuke it for you: `Get-WmiObject Win32_service -filter "displayname = ''" |select -expandproperty name |foreach { sc.exe delete "$_" }` – Ian Kemp Mar 21 '18 at 15:51
  • You can also find the proper name for method 1 by going to the Services tab in Task Manager – Andrew Keeton Sep 20 '19 at 16:51
172

From the command prompt, use the Windows "sc.exe" utility. You will run something like this:

sc delete <service-name>
Dean Hill
  • 4,199
  • 6
  • 26
  • 34
27

Notes on using "sc delete" in Windows 8:

1) Open a CMD window with elevated privileges. [Windows Key-X to bring up a menu with the option; select "Command Prompt (Admin)".]
2) Use the parenthetical name from the list in Services [for example, I used "sc delete gupdate" when, in Services, it read "Google Update (gupdate)"]

Michael
  • 271
  • 3
  • 2
22

Some people mentioning sc delete as an answer. This is how I did it, but it took me a while to find the <service-name> parameter.

The command sc query type= service (note, it's very particular with formatting, the space before "service" is necessary) will output a list of Windows services installed, complete with their qualified name to be used with sc delete <service-name> command.

The list is quite long so you may consider piping the output to a text file (i.e. >> C:\test.txt) and then searching through that.

The SERVICE_NAME is the one to use with sc delete <service-name> command.

Ian Kemp
  • 24,155
  • 16
  • 97
  • 121
Robin French
  • 625
  • 6
  • 17
  • 2
    See my comment on the accepted answer. The service name can be determined quickly by looking at the Properties sheet for the service in the Services panel. – donperk Sep 15 '14 at 18:39
  • 2
    That was totally unnecessary: if they show up in the services list, you can just open the properties of the services you want to remove from the services list, *in* the services list, and it will show you the service name. The "service name" listed in the properties there is the same service name, too. :) – neminem Sep 07 '17 at 02:21
  • 2
    Yeah I know you can get to the name by other means. I added this because I had trouble figuring out which of the names to use in the command. I had seen the name listed in the service properties, but I didn't know at the time that was the name to use in the command. Using the command line was a good way for me to dump out all the installed services, including the to use to remove. I had a couple of services that needed this so it was easier for me to dump the whole list out to file so I could get to them without having to look it up in the services snap-in. – Robin French Sep 07 '17 at 17:52
  • 1
    You can just run `sc query` as it defaults to `type= service`. – Ian Kemp Mar 21 '18 at 13:02
12

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
10

If you wish to use a tool for it you could use Process Hacker

Form to create the service:

Process Hacker Create Service

Context menu on a service to delete it:

Process Hacker Delete Service

I find Process Hacker a more convient tool to manage Windows processes and services than Windows's own Taskmgr.exe. Especially on Windows XP, where you can't access services at all from task manager.

Mike de Klerk
  • 10,430
  • 7
  • 46
  • 68
5

I needed to reinstall my tomcat service, which meant first removing it. This worked for me:

Start a command prompt window using run as administrator

sc query type= service >t.txt

(edit the file t.txt, search through the list and find the tomcat service. It's called Tomcat7)

sc delete Tomcat7

HOWEVER, the query command did not work the first time, because the tomcat service was not running. It seems to only list services that are running. I had to start the service and run the query command again.

user1208639
  • 195
  • 1
  • 4
3

If the original Service .InstallLog and .InstallState files are still in the folder, you can try reinstalling the executable to replace the files, then use InstallUtil /u, then uninstall the program. It's a bit convoluted, but worked in a particular instance for me.

ja928
  • 418
  • 3
  • 16
3

You can try running Autoruns, which would save you from having to edit the registry by hand. This is especially useful when you don't have the needed permissions.

Tan
  • 213
  • 1
  • 7
0

You can uninstall your windows service by command prompt also just write this piece of command

cd\                                                                   

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319(or version in which you developed your service)                                           

installutil c:\\xxx.exe(physical path of your service) -d
3rdthemagical
  • 4,687
  • 13
  • 30
0

1st Step : Move to the Directory where your service is present

Command : cd c:\xxx\yyy\service

2nd Step : Enter the below command

Command : C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe service.exe \u

Here service.exe is your service exe and \u will uninstall the service. you'll see "The uninstall has completed" message.

If you wanna install a service, Remove \u in the above command which will install your service

Sree
  • 9
  • 2
0

We discovered that even if you run sc_delete, there can be an entry remaining in the registry for your service, so that reinstalling the service results in a corrupted set of registry entries (they don't match). What we did was to regedit and remove this leftover entry by hand.

Note: ShipmunkService is still showing up after sc_delete!

Then you can reinstall, and your service will run correctly. Best of luck to you all, and may the force be with you.

barclay
  • 3,955
  • 8
  • 43
  • 65
0

-Windows+r open cmd.

-sc YourSeviceName this code remove your service.

-Uninstal "YourService Path" this code uninstall your service.

sajas
  • 1,479
  • 17
  • 37
0

The easiest way is to use Sys Internals Autoruns

enter image description here

Start it in admin mode and then you can remove obsolete services by delete key