Introduction
nssm is a service encapsulation program, which can encapsulate ordinary exe programs into services and make them run like windows services. Microsoft's own srvany is the same type of tool, but nssm is easier to use and powerful.
Its characteristics are as follows:
- Support ordinary exe program (console program or Windows program with interface are both possible)
- Easy to install and easy to modify
- Can redirect output (and supports Rotation)
- The packaged service can be automatically guarded, and the program can be automatically restarted after the program hangs.
- You can customize environment variables
download
installation
After the download is complete, select the 32-bit or 64-bit nssm.exe according to the number of bits of the operating system.
The following takes the installation of Snipaste as an example to show the installation process.
- Open cmd with administrator privileges, enter the directory where nssm.exe is located, run the command
nssm install Snipaste
, and the following interface will pop up:
Path
It is the name of the running program with path; itStartup diretory
is the running path, that is, the directory where the running program is located;Arguments
it is the startup parameter of the program; click after filling inInstall Service
, the execution is successful, and the prompt is as follows:
- At this time, just set the program as a service, and the service is still closed . To start the service, run the command:
nssm start Snipaste
OK. If the command fails to start the service , you can run the command directlyservices.msc
and open the service interface to manually start the Snipaste service.
Command summary
nssm start servername //启动服务
nssm stop servername //暂停服务
nssm restart servername //重新启动服务
nssm remove servername //删除创建的servername服务
reference
Windows uses NSSM to encapsulate any exe as a service
NSSM-the Non-Sucking Service Manager