Windows has two small tools, instsrv.exeand srvany.exe, to package any applications into windows services. Instsrv (install service) is used to install services. srvany (service anything) encapsulates the shells of any services.
Download instsrv.exeand srvany.exe first, and you can go to the Baidu download address step. The steps are as follows:
1. First, use instsrvto install srvanyinto a service. The instsrvcommand format (instsrv.exe /?) :
| The code is as follows: |
Copy code |
Installand removes system services from NT INSTSRV <service name> (<exe location> | REMOVE) [-A <Account Name>] [-p <Account Password>] Install service example: INSTSRV MyService C: MyDirDiskService. Exe -OR- INSTSRV MyService C: mailsrvmailsrv.exe-a MYDOMAINjoebob-p foo Remove service example: INSTSRV MyService REMOVE |
Location is the complete path.
Therefore, my installation commands
| The code is as follows: |
Copy code |
| Instsrv.exe nginx e: tempclean_daynginx-1.4.7srvany.exe |
2. The first step is to install the service shell. Here we need to configure this shell to execute the real application. Modify the registry
Run regedit.exe and open registry editor ";
Expand the following sub-keys in sequence: [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices]. Find and right-click nginx under the sub-key (corresponding to the service name created in step 1) and select "item" under "new ", name it Parameters.
Click Select Parameters, create a new string value named Application in the right window, set its numeric data to the absolute path of the Application corresponding to the nginx service, for example: E: tempclean_daynginx-1.4.7nginx.exe;
Then create two new string values: AppDirectory and AppParameters, AppDirectory specifies the directory where the program is located, such as: E: tempclean_daynginx-1.4.7;
AppParameters indicates the program running parameter. If not, you do not need to set a value;
3. Start the service
You can use the net command to start/stop or SC command to configure the service.
4. Delete a service
You can use the remove option of instsrv to delete the service, or use the SC command.
For convenience, you can also create bat files, including installation, uninstallation, start, stop, and even registry operations. If you are interested, try it yourself.