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

Viewed 798333

How do I uninstall a .NET Windows Service if the service files do not exist 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?

15 Answers

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)

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

sc delete <service-name>

If the service name has one or more spaces, surround the name in double quotes (h/t @geoffc):

sc delete "<service-name>"

Lots of great answers and this really helped me, but there was one thing that was missing. There's a mention of finding the service through cmd with sc query type= service but the problem is that the service I was looking for wasn't running and this command only shows running services (which may be a new feature that didn't exist at the time of the OP answer).

You have to pass the state of the service to the command like this sc query state= all or sc query state= inactive There's no need to pass the type= service because that is the default.

And, as stated above, push it to a text file so it's easier to search sc query state= inactive > C:\servicesStopped.txt

Source: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/sc-query

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

Related