[windows] How do I uninstall a Windows service if the files do not exist anymore?

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?

This question is related to windows windows-services installation

The answer is


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)


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)"]


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


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.


-Windows+r open cmd.

-sc YourSeviceName this code remove your service.

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


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.


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

sc delete <service-name>

-Windows+r open cmd.

-sc YourSeviceName this code remove your service.

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


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.


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.


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

sc delete <service-name>

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.


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.


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.


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.


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

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.


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.


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

sc delete <service-name>

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.


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)"]


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


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.


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


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

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.


Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to windows-services

Can't start Tomcat as Windows Service Error 1053 the service did not respond to the start or control request in a timely fashion How to solve "The specified service has been marked for deletion" error Service will not start: error 1067: the process terminated unexpectedly How to get all Windows service names starting with a common word? Windows service with timer Windows service on Local Computer started and then stopped error Windows service start failure: Cannot start service from the command line or debugger "Automatic" vs "Automatic (Delayed start)" How to install node.js as windows service?

Examples related to installation

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) Conda version pip install -r requirements.txt --target ./lib How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" PackagesNotFoundError: The following packages are not available from current channels: Tensorflow import error: No module named 'tensorflow' Downgrade npm to an older version Create Setup/MSI installer in Visual Studio 2017 how to install tensorflow on anaconda python 3.6 Application Installation Failed in Android Studio How to install pip for Python 3.6 on Ubuntu 16.10?