Introduction

NSSM stands for “Non-Sucking Service Manager,” and it is an open-source utility for Windows that allows you to easily run any program as a Windows service. The name “Non-Sucking Service Manager” humorously suggests that it is a better alternative to the built-in Windows Service Manager.

Windows services are background processes that can be started automatically during system boot and run independently of any user login. They are typically used for tasks that need to run continuously in the background, such as server applications, daemons, or background services.

NSSM provides a simple command-line interface that enables you to install, remove, and manage services. It wraps around the Windows Service Control Manager (SCM) and provides additional functionalities that make it easier to set up and run various applications as services.

Features of NSSM

  • Application as a Service: NSSM allows you to convert any executable (EXE) into a Windows service, allowing it to start automatically and run in the background.
  • Process Monitoring: NSSM can monitor the status of the service and automatically restart it if it crashes or terminates unexpectedly.
  • Standard I/O Redirection: NSSM allows you to redirect standard input, output, and error streams, making it easier to handle log files and debugging.
  • Graceful Shutdown: It provides options to gracefully shut down the service when the system is shutting down.
  • Environment Variables: You can set up environment variables specific to the service.
  • Service Dependency: NSSM allows you to specify dependencies on other services to ensure proper service startup order.
  • Interactive Service: It enables you to run an interactive application (one that requires user input) as a service.
  • Pre/Post-execution Hooks: NSSM supports pre- and post-execution hooks, allowing you to run custom scripts or commands before and after the service starts or stops.

How to use

Using GUI

  • Download the utitlity from this link: https://nssm.cc/release/nssm-2.24.zip
  • Extract the downloaded .zip file.
  • Move to proper directory I.E Program Files
  • run .\nssm.exe install UT2003
  • It creates a service name called: UT2003
  • A Gui will show, specify the app path like this one: Image alt
  • Change any necessary setting, and Install service
  • You will see a new service name called UT2003 on the services list on services.msc

Equivalent cmdline command

nssm install <servicename> # install a service
nssm set UT2003 Application C:\games\ut2003\System\UCC.exe # Set app path
nssm set UT2003 AppDirectory C:\games\ut2003\System # Set Startup directory path
nssm set UT2003 AppParameters server # App Argument / parameter
nssm set UT2003 DisplayName UT2k3 # Set Service's Display Name.
nssm set UT2003 Description Unreal Tournament 2003 # Set Service's Description.
nssm set UT2003 Start SERVICE_AUTO_START # Startup Type
nssm set UT2003 ObjectName LocalSystem  # Set Log on As "Local System Account"
nssm set UT2003 Type SERVICE_WIN32_OWN_PROCESS # Set log as an account. Username and Password is required.
nssm set UT2003 DependOnService MpsSvc # Set dependencies

Conclusion

NSSM is particularly useful for running third-party applications or scripts as services, especially those that were not originally designed to run as Windows services. It can be helpful in situations where you want to run a custom application continuously on a Windows machine without requiring a user to be logged in.