Run a program as a service in Windows

less than 1 minute read

This tutorial is based on Windows 8.1 + NSSM 2.21.1 but should work with other versions as well.

Setup

  1. Download NSSM (the Non-Sucking Service Manager)
  2. Open the archive and extract the win32 or win64 directory (depending on your Windows installation’s architecture, you can check this by pressing Windows Key + Pause) Note: As there is no installer, you should extract the file to a safe location, for example C:\Program Files\NSSM
  3. Open a command window with administrator privileges
    1. Open start
    2. Type cmd
    3. Right-click on cmd and choose Run as administrator
  4. Navigate to your NSSM directory, for example:
    cd "C:\Program Files\NSSM"
    
  5. Type nssm install and press enter
  6. Select the program to run as a service by clicking ... after Path
  7. Give the service a name (Service name)
  8. Click Install service

You’re done. You’ve installed a normal program as a service. It’s possible to define more settings, but these are the minimal settings required.

Note: if you’re coming from Install nginx and PHP on Windows, use -b 127.0.0.1:9000 in the Options field.

Managing services

  1. Open start
  2. Type services.msc and press enter
  3. Search for your service
  4. Right-click your service to manage it (start, stop, restart etc)

Updated:

Leave a comment