Home  >  Article  >  Backend Development  >  Register exe as windows service instance tutorial

Register exe as windows service instance tutorial

零下一度
零下一度Original
2017-06-24 09:59:192197browse

1. Tools required

Instsrv.exe (can install and delete services for the system)

Srvany.exe (can run the program as a service)

2. Run cmd and enter the registration service command

 "Full path to instsrv.exe" "Service name" "Full path to srvany.exe"

D:\instsrv.exe ObjProjcet D:\srvany .exe

3. Open the registry, shortcut window + r, enter regedit, enter the registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, right-click on the service name you just created (such as ObjProjcet) and create a new item "Parameters" , click to select it and then create a new string value in the right window with the name "Application", the value is the path of the service you want to run, the path requires double slashes "\\", and then you can create an AppDirectory designated program The initial directory for running (optional) is created in the same way as "Application". This is used as the running directory of the program. If not set, it will generally default to the C drive. If you need to make the service you register look more professional and easier to understand, you can continue to create a new string value named "Description", in which you can enter the service description you want to display.

4. Step 3 can be done directly through the reg add command syntax of the cmd command Note 3:

REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ services\ObjProjcet\Parameters"

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ObjProjcet\Parameters /v Application(AppDirectory) /t REG_SZ /d D:\\ObjProjcet\\Project.exe /f

Note:

1. Create a new item, ObjProjcet (service name)\Parameters

2. Enter REG ADD /? View REG ADD command help

3. Reg add command syntax: reg reg add "Path of the item to be added" /v "Value name" /t "Data type" /d "Value" /f

 4./v to specify the name; /t data type; /d to specify the content; /f to force work ;

## 5. The /f parameter means forced modification without confirmation. Sometimes there may be problems if the command is too long. You can change the way without using the /f parameter. Write like this: echo y|reg add *************

Reference:

1. How to register any exe program as a windows system service

2. How to write a BAT file to automatically add the registry?

The above is the detailed content of Register exe as windows service instance tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn