How to create or delete Windows services

By Pranay
24 May '20  ·  3616 views

Windows service is a process running in the background on a windows operating system. It can be configured to start automatically or by an event. They run in the context of their own dedicated user accounts and can operate even when the user is not logged on.

To create a windows service:

The SC Tool (sc.exe) is a tool used for communicating with the Service Control Manager and services either locally or remotely on a windows server.

Syntax: sc <server> [command] [service name] <option1> <option2>…

<server> - This is optional. It refers to the remote server name on which you are going to create the windows service. If you are creating service on a local server then you can ignore this field.

[command] - The command we are going to use here is ‘create’ i.e., to create a new windows service. There are many other commands available.

[service name] – it is the name of the windows service which we are going to create.

<option1> - Many options are available but we are going to use ‘binpath=”.exe file path”’ only. Formore details on this you can refer to the msdn link.

Command: SC create servicename binpath ="C:\MyWinServices\Test.exe"

Note: To delete an existing windows service: Instead of creating a service if you want to delete an existing service you canuse ‘delete’ command instead of ‘create’ as shown below.

Delete Command: SC delete servicenamebinpath = "C:\MyWinServices\Test.exe"

About the author

Pranay Deegoju
Sitecore Certified Professional

A Software Engineer by profession, a part time blogger and an enthusiast programmer. You can find more about me here.

Post a comment

Recent Posts


Liked this article?

Subscribe with your email and get updates when ever a new article is posted.

By subscribing you agree to our privacy terms. We promise that we do not sell your data.