How To Make A Windows Service

Table of contents:

How To Make A Windows Service
How To Make A Windows Service

Video: How To Make A Windows Service

Video: How To Make A Windows Service
Video: Intro to Windows Services in C# - How to create, install, and use a service using Topshelf 2024, May
Anonim

The operation of creating a Windows service is performed using the specialized utility Sc.exe, the parameters of which are edited in the command interpreter.

How to make a Windows service
How to make a Windows service

Instructions

Step 1

Call the main menu of the Microsoft Windows operating system to perform the operation of creating a system service and go to the "Run" item.

Step 2

Enter the value cmd in the "Open" field and confirm the launch of the "Command Line" tool by clicking the OK button.

Step 3

Use the following command syntax to define the parameters for the service you are creating:

sc Servername Command Servicename Optionname = Optionvalue …

or use the value

sc Command

to call up help information.

Step 4

Remember that the Servername parameter is not used when creating a service on the local computer and is only needed when specifying the name of the remote server to run commands.

Step 5

Use the Config parameter to edit the persistent settings for the service you are creating and select Continue to send the appropriate request.

Step 6

Use the Control parameter to execute the selected request and use the Create parameter to add the created service to the system registry.

Step 7

Select the EnumDepend parameter to define the service dependencies and specify the service section names in the GetKeyName value.

Step 8

Determine the configuration of the selected service with a qc query, or determine the state of the service by entering the Query parameter.

Step 9

Use the Start value to start, Stop to stop, and Delete to delete the newly created service.

Step 10

Determine the name assigned to the system service in the registry using the Servicename parameter. Note that this name is not the same as the name displayed by the net start command in the Services group of the management console.

Step 11

Use the Optionname and Optionvalue parameters to specify the names and values of the optional parameters you need (if necessary), and specify the value for each of the selected parameters separately.

Step 12

Specify the full path to the bin file of the service in the binPath parameter and specify the ownership group of the service being created in the group line.

Step 13

Use the depend = parameter to define the services and groups to be pre-started, and specify the username for which the service is to be started in the obj = parameter. The default value for this parameter is LocalSystem.

Step 14

Use the password = parameter to define a password value and specify the service name used in GUI applications in the DisplayName parameter.

Step 15

Use the following command syntax to create a test system service named service:

sc create service binpath = drive_name: / int / system32 / serv.exe.

Recommended: