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"
No comments:
Post a Comment