Many a times I have been in a situation where I need to delete a windows service and every time I end up “googling” to find the easiest/fastest way of doing this. Most of the posts in the search result talk about modifying the windows registry to delete the service, which isn’t always foolproof.
The easisest way of deleting a service is by using the sc.exe command line tool. This tools comes bundled with Windows and is probably the easiest way of maintaining and administering Windows Services.
Lets take an example of a totally useless service on Windows: Windows Search Service.
The first thing to do is to get the name of the Windows Service; What is shown in the service list (Control Panel -> Administrative Tools -> Services) is the Display name and this cannot be used as an input to sc.exe. The example service we have chosen has the name “WSearch” as shown below:
To delet the above service all I need to do is to execute the following command
sc delete WSearch
The SC tool comes in handy for many operations other than delete. A detailed description of this tool can be found in the following knowledge base article.
You can always disable a service, but if you are in a situation where you need to delete a service, the above tool definitely comes in handy.