Register exe as a windows Service and exe as a windows Service
1. Tools Required
Instsrv.exe (you can install and delete services for the System)
Srvany.exe (allows programs to run as services)
2. Run cmd and enter the registration service command
"Instsrv.exe full path" "service name" "srvany.exe full path"
D: \ instsrv.exe ObjProjcet D: \ srvany.exe
3. open the registry, enter regedit in the shortcut window + r, and enter the Registry HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services. Right-click the service name (such as ObjProjcet) You just created and choose "Parameters ", click Select it and create a new string value named "Application" in the window on the right. The value is the path of the service to be run. The path must be a double slash "\\", then, you can create an AppDirectory to specify the initial directory for running the program (optional) in the same way as "Application", which is used to run the program directory. If this is not set, it is usually in disk C by default. If you need to make the service you have registered more professional and better understood, you can create a new string value named "Description ", you can enter the service description you want to display in the value.
4. Step 3 You can directly use 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. New item, ObjProjcet (Service name) \ Parameters
2. Enter reg add /? View reg add Command help
3. reg add command syntax: reg add "item path 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 does not need to be confirmed. Sometimes the command is too long and may be a problem. you can use another method without the/f parameter. write echo y | reg add ***********
References:
1. How to register any exe program as a windows system service
2. How can I use the BAT file to automatically add a registry?