Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active June 5, 2024 01:05
Show Gist options
  • Save magnetikonline/2217fd95cf15a0324696 to your computer and use it in GitHub Desktop.
Save magnetikonline/2217fd95cf15a0324696 to your computer and use it in GitHub Desktop.
NSSM - the Non-Sucking Service Manager cheatsheet.

NSSM cheatsheat

See: NSSM - the Non-Sucking Service Manager

Create a new service

nssm.exe install SERVICE_NAME "C:\path\to\exe\or\bat\file.ext" "argument1 argument2"

List parameters for a service

nssm.exe get SERVICE_NAME *

Set a parameter for a service

nssm.exe set SERVICE_NAME PARAMETER_NAME PARAMETER_VALUE
nssm.exe set SERVICE_NAME Description "My service description."
nssm.exe set SERVICE_NAME Start SERVICE_AUTO_START
nssm.exe set SERVICE_NAME AppExit Default Exit
nssm.exe set SERVICE_NAME AppStdout "C:\log\service-output.log"

Parameter list

AppAffinity
AppDirectory
AppEnvironment
AppEnvironmentExtra
AppExit
Application
AppNoConsole
AppParameters
AppPriority
AppRestartDelay
AppRotateBytes
AppRotateBytesHigh
AppRotateFiles
AppRotateOnline
AppRotateSeconds
AppStderr
AppStderrCreationDisposition
AppStderrFlagsAndAttributes
AppStderrShareMode
AppStdin
AppStdinCreationDisposition
AppStdinFlagsAndAttributes
AppStdinShareMode
AppStdout
AppStdoutCreationDisposition
AppStdoutFlagsAndAttributes
AppStdoutShareMode
AppStopMethodConsole
AppStopMethodSkip
AppStopMethodThreads
AppStopMethodWindow
AppThrottle
DependOnGroup
DependOnService
Description
DisplayName
ImagePath
Name
ObjectName
Start
Type
@dybxin
Copy link

dybxin commented May 28, 2021

@dybxin you'll probably have to make a PowerShell/batch file and execute that? Otherwise treat each exe as an isolated service.

likely: the following demo.bat file.

start /d "E:\minio\minio.exe" minio.exe server E:\minio\data

ping /n 10 127.0.0.1>nul

start /d "E:\demo\a.exe" a.exe -format=http

ping /n 10 127.0.0.1>nul

...

or

SETLOCAL
SET PATH="E:\demo\minio"

start /wait minio.exe server E:\demo\minio\data

SETLOCAL
SET PATH="E:\demo\xxx"

start /wait a.exe -format=http

start /wait b.exe -format=http

start /wait c.exe -format=http

@jtcoyle
Copy link

jtcoyle commented Aug 13, 2021

I need to be able to stop and start the service under a standard user account. I have tried to use the runas command (See Below) but I have not had any luck to get it to work.

C:\windows\system32>runas /user:server\support /savecred "c:\kds\nssm stop KDS_MANAGER"
Attempting to start c:\kds\nssm stop KDS_MANAGER as user "server\support" ...

I see a window open and close very fast but the service does not stop

If I use "nssm stop KDS_MANAGER" on the same command prompt the service stops but this only works if the CMD prompt is run as administrator or I need to provide credentials. I am trying to get this to run without having to enter admin credentials.

I have also tried using batch files with no luck.

Any help to solve this would be greatly appreciated.

Regards,

Joe

@moeshin
Copy link

moeshin commented Jan 22, 2022

How to fix program not executing at fast startup (fast boot)?
It's normal to restart windows. But shutdown and then on, the program will not be executed.

@gonbaum
Copy link

gonbaum commented Dec 30, 2022

My node app running through nssm is restarting, again and again, every ~20 secs, but not showing any error. Any idea of which could be the cause? I'm running nssm start <service> through a cmd script in a cmd prompt with administrator rights.

@alexqfredrickson
Copy link

I would like to silently install a service for WildFly in a single command and include the user and password to run the service.

This is what I have so far:

nssm install Wildfly15 D:\wildfly-15.0.1.Final\bin\standalone.bat "-b=127.0.0.1 --debug"

This is OK. It opens the dialog box. Can nssm me used silently and can you add logon username and password?

Not sure, but you can silently remove services. nssm remove <servicename> confirm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment