{"id":18822639,"url":"https://github.com/dkxce/nssm","last_synced_at":"2025-09-02T21:32:59.419Z","repository":{"id":44757395,"uuid":"442705936","full_name":"dkxce/NSSM","owner":"dkxce","description":"The Non-Sucking Service Manager","archived":false,"fork":false,"pushed_at":"2021-12-29T08:59:03.000Z","size":7313,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T00:51:57.692Z","etag":null,"topics":["api","console","net","nssm","service","services","start","stop","svc","win"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkxce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-29T08:17:04.000Z","updated_at":"2024-11-06T11:22:03.000Z","dependencies_parsed_at":"2022-08-30T05:32:24.107Z","dependency_job_id":null,"html_url":"https://github.com/dkxce/NSSM","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkxce%2FNSSM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkxce%2FNSSM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkxce%2FNSSM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkxce%2FNSSM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkxce","download_url":"https://codeload.github.com/dkxce/NSSM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231810774,"owners_count":18430012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","console","net","nssm","service","services","start","stop","svc","win"],"created_at":"2024-11-08T00:50:48.529Z","updated_at":"2024-12-30T04:17:36.479Z","avatar_url":"https://github.com/dkxce.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NSSM: The Non-Sucking Service Manager\n\n### Version 2.25    \n\nNSSM is a service helper program similar to srvany and cygrunsrv.  It can \nstart any application (such as console) as an NT service and will restart \nthe service if it fails for any reason.\n\nNSSM also has a graphical service installer and remover.\n\n### About\n\nThis is a fork of [NSSM](https://nssm.cc/)    \nBinary files you can find [in releases here](https://github.com/dkxce/NSSM/releases)     \nOriginal code: https://git.nssm.cc/nssm/nssm by [Iain Patterson](https://git.nssm.cc/iain)    \nDocumentation: [Usage](Usage.md), [Commands](commands.md)    \n\nUsage\n-----\nIn the usage notes below, arguments to the program may be written in angle\nbrackets and/or square brackets.  \u003cstring\u003e means you must insert the\nappropriate string and [\u003cstring\u003e] means the string is optional.  See the\nexamples below...\n\nNote that everywhere \u003cservicename\u003e appears you may substitute the\nservice's display name.\n\n\nInstallation using the GUI\n--------------------------\nTo install a service, run\n\n    nssm install \u003cservicename\u003e\n\nYou will be prompted to enter the full path to the application you wish \nto run and any command line options to pass to that application.\n\nUse the system service manager (services.msc) to control advanced service \nproperties such as startup method and desktop interaction.  NSSM may \nsupport these options at a later time...\n\n\nInstallation using the command line\n-----------------------------------\nTo install a service, run\n\n    nssm install \u003cservicename\u003e \u003capplication\u003e [\u003coptions\u003e]\n\nNSSM will then attempt to install a service which runs the named application \nwith the given options (if you specified any).\n\nDon't forget to enclose paths in \"quotes\" if they contain spaces!\n\nIf you want to include quotes in the options you will need to \"\"\"quote\"\"\" the\nquotes.\n\n\nManaging the service\n--------------------\nNSSM will launch the application listed in the registry when you send it a \nstart signal and will terminate it when you send a stop signal.  So far, so \nmuch like srvany.  But NSSM is the Non-Sucking service manager and can take \naction if/when the application dies.\n\nWith no configuration from you, NSSM will try to restart itself if it notices\nthat the application died but you didn't send it a stop signal.  NSSM will\nkeep trying, pausing between each attempt, until the service is successfully\nstarted or you send it a stop signal.\n\nNSSM will pause an increasingly longer time between subsequent restart attempts\nif the service fails to start in a timely manner, up to a maximum of four\nminutes.  This is so it does not consume an excessive amount of CPU time trying\nto start a failed application over and over again.  If you identify the cause\nof the failure and don't want to wait you can use the Windows service console\n(where the service will be shown in Paused state) to send a continue signal to\nNSSM and it will retry within a few seconds.\n\nBy default, NSSM defines \"a timely manner\" to be within 1500 milliseconds.\nYou can change the threshold for the service by setting the number of\nmilliseconds as a REG_DWORD value in the registry at\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppThrottle.\n\nAlternatively, NSSM can pause for a configurable amount of time before\nattempting to restart the application even if it successfully ran for the\namount of time specified by AppThrottle.  NSSM will consult the REG_DWORD value\nat HKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppRestartDelay\nfor the number of milliseconds to wait before attempting a restart.  If\nAppRestartDelay is set and the application is determined to be subject to\nthrottling, NSSM will pause the service for whichever is longer of the\nconfigured restart delay and the calculated throttle period.\n\nIf AppRestartDelay is missing or invalid, only throttling will be applied.\n\nNSSM will look in the registry under\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppExit for\nstring (REG_EXPAND_SZ) values corresponding to the exit code of the application.\nIf the application exited with code 1, for instance, NSSM will look for a\nstring value under AppExit called \"1\" or, if it does not find it, will\nfall back to the AppExit (Default) value.  You can find out the exit code\nfor the application by consulting the system event log.  NSSM will log the\nexit code when the application exits.\n\nBased on the data found in the registry, NSSM will take one of three actions:\n\nIf the value data is \"Restart\" NSSM will try to restart the application as\ndescribed above.  This is its default behaviour.\n\nIf the value data is \"Ignore\" NSSM will not try to restart the application\nbut will continue running itself.  This emulates the (usually undesirable)\nbehaviour of srvany.  The Windows Services console would show the service\nas still running even though the application has exited.\n\nIf the value data is \"Exit\" NSSM will exit gracefully.  The Windows Services\nconsole would show the service as stopped.  If you wish to provide\nfiner-grained control over service recovery you should use this code and\nedit the failure action manually.  Please note that Windows versions prior\nto Vista will not consider such an exit to be a failure.  On older versions\nof Windows you should use \"Suicide\" instead.\n\nIf the value data is \"Suicide\" NSSM will simulate a crash and exit without\ninforming the service manager.  This option should only be used for\npre-Vista systems where you wish to apply a service recovery action.  Note\nthat if the monitored application exits with code 0, NSSM will only honour a\nrequest to suicide if you explicitly configure a registry key for exit code 0.\nIf only the default action is set to Suicide NSSM will instead exit gracefully.\n\n\nApplication priority\n--------------------\nNSSM can set the priority class of the managed application.  NSSM will look in\nthe registry under HKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\nfor the REG_DWORD entry AppPriority.  Valid values correspond to arguments to\nSetPriorityClass().  If AppPriority() is missing or invalid the\napplication will be launched with normal priority.\n\n\nProcessor affinity\n------------------\nNSSM can set the CPU affinity of the managed application.  NSSM will look in\nthe registry under HKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\nfor the REG_SZ entry AppAffinity.   It should specify a comma-separated listed\nof zero-indexed processor IDs.  A range of processors may optionally be\nspecified with a dash.  No other characters are allowed in the string.\n\nFor example, to specify the first; second; third and fifth CPUs, an appropriate\nAppAffinity would be 0-2,4.\n\nIf AppAffinity is missing or invalid, NSSM will not attempt to restrict the\napplication to specific CPUs.\n\nNote that the 64-bit version of NSSM can configure a maximum of 64 CPUs in this\nway and that the 32-bit version can configure a maxium of 32 CPUs even when\nrunning on 64-bit Windows.\n\n\nStopping the service\n--------------------\nWhen stopping a service NSSM will attempt several different methods of killing\nthe monitored application, each of which can be disabled if necessary.\n\nFirst NSSM will attempt to generate a Control-C event and send it to the\napplication's console.  Batch scripts or console applications may intercept\nthe event and shut themselves down gracefully.  GUI applications do not have\nconsoles and will not respond to this method.\n\nSecondly NSSM will enumerate all windows created by the application and send\nthem a WM_CLOSE message, requesting a graceful exit.\n\nThirdly NSSM will enumerate all threads created by the application and send\nthem a WM_QUIT message, requesting a graceful exit.  Not all applications'\nthreads have message queues; those which do not will not respond to this\nmethod.\n\nFinally NSSM will call TerminateProcess() to request that the operating\nsystem forcibly terminate the application.  TerminateProcess() cannot be\ntrapped or ignored, so in most circumstances the application will be killed.\nHowever, there is no guarantee that it will have a chance to perform any\ntidyup operations before it exits.\n\nAny or all of the methods above may be disabled.  NSSM will look for the\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppStopMethodSkip\nregistry value which should be of type REG_DWORD set to a bit field describing\nwhich methods should not be applied.\n\n  If AppStopMethodSkip includes 1, Control-C events will not be generated.\n  If AppStopMethodSkip includes 2, WM_CLOSE messages will not be posted.\n  If AppStopMethodSkip includes 4, WM_QUIT messages will not be posted.\n  If AppStopMethodSkip includes 8, TerminateProcess() will not be called.\n\nIf, for example, you knew that an application did not respond to Control-C\nevents and did not have a thread message queue, you could set AppStopMethodSkip\nto 5 and NSSM would not attempt to use those methods to stop the application.\n\nTake great care when including 8 in the value of AppStopMethodSkip.  If NSSM\ndoes not call TerminateProcess() it is possible that the application will not\nexit when the service stops.\n\nBy default NSSM will allow processes 1500ms to respond to each of the methods\ndescribed above before proceeding to the next one.  The timeout can be\nconfigured on a per-method basis by creating REG_DWORD entries in the\nregistry under HKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters.\n\n  AppStopMethodConsole\n  AppStopMethodWindow\n  AppStopMethodThreads\n\nEach value should be set to the number of milliseconds to wait.  Please note\nthat the timeout applies to each process in the application's process tree,\nso the actual time to shutdown may be longer than the sum of all configured\ntimeouts if the application spawns multiple subprocesses.\n\nTo skip applying the above stop methods to all processes in the application's\nprocess tree, applying them only to the original application process, set the\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppKillProcessTree\nregistry value, which should be of type REG_DWORD, to 0.\n\n\nConsole window\n--------------\nBy default, NSSM will create a console window so that applications which\nare capable of reading user input can do so - subject to the service being\nallowed to interact with the desktop.\n\nCreation of the console can be suppressed by setting the integer (REG_DWORD)\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppNoConsole\nregistry value to 1.\n\n\nI/O redirection\n---------------\nNSSM can redirect the managed application's I/O to any path capable of being\nopened by CreateFile().  This enables, for example, capturing the log output\nof an application which would otherwise only write to the console or accepting\ninput from a serial port.\n\nNSSM will look in the registry under\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters for the keys\ncorresponding to arguments to CreateFile().  All are optional.  If no path is\ngiven for a particular stream it will not be redirected.  If a path is given\nbut any of the other values are omitted they will be receive sensible defaults.\n\n  AppStdin: Path to receive input.\n  AppStdout: Path to receive output.\n  AppStderr: Path to receive error output.\n\nParameters for CreateFile() are providing with the \"AppStdinShareMode\",\n\"AppStdinCreationDisposition\" and \"AppStdinFlagsAndAttributes\" values (and\nanalogously for stdout and stderr).\n\nIn general, if you want the service to log its output, set AppStdout and\nAppStderr to the same path, eg C:\\Users\\Public\\service.log, and it should\nwork.  Remember, however, that the path must be accessible to the user\nrunning the service.\n\n\nFile rotation\n-------------\nWhen using I/O redirection, NSSM can rotate existing output files prior to\nopening stdout and/or stderr.  An existing file will be renamed with a\nsuffix based on the file's last write time, to millisecond precision.  For\nexample, the file nssm.log might be rotated to nssm-20131221T113939.457.log.\n\nNSSM will look in the registry under\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters for REG_DWORD\nentries which control how rotation happens.\n\nIf AppRotateFiles is missing or set to 0, rotation is disabled.  Any non-zero\nvalue enables rotation.\n\nIf AppRotateSeconds is non-zero, a file will not be rotated if its last write\ntime is less than the given number of seconds in the past.\n\nIf AppRotateBytes is non-zero, a file will not be rotated if it is smaller\nthan the given number of bytes.  64-bit file sizes can be handled by setting\na non-zero value of AppRotateBytesHigh.\n\nIf AppRotateDelay is non-zero, NSSM will pause for the given number of\nmilliseconds after rotation.\n\nIf AppStdoutCopyAndTruncate or AppStderrCopyAndTruncate are non-zero, the\nstdout (or stderr respectively) file will be rotated by first taking a copy\nof the file then truncating the original file to zero size.  This allows\nNSSM to rotate files which are held open by other processes, preventing the\nusual MoveFile() from succeeding.  Note that the copy process may take some\ntime if the file is large, and will temporarily consume twice as much disk\nspace as the original file.  Note also that applications reading the log file\nmay not notice that the file size changed.  Using this option in conjunction\nwith AppRotateDelay may help in that case.\n\nRotation is independent of the CreateFile() parameters used to open the files.\nThey will be rotated regardless of whether NSSM would otherwise have appended\nor replaced them.\n\nNSSM can also rotate files which hit the configured size threshold while the\nservice is running.  Additionally, you can trigger an on-demand rotation by\nrunning the command\n\n    nssm rotate \u003cservicename\u003e\n\nOn-demand rotations will happen after the next line of data is read from\nthe managed application, regardless of the value of AppRotateBytes. Be aware\nthat if the application is not particularly verbose the rotation may not\nhappen for some time.\n\nTo enable online and on-demand rotation, set AppRotateOnline to a non-zero\nvalue.\n\nNote that online rotation requires NSSM to intercept the application's I/O\nand create the output files on its behalf.  This is more complex and\nerror-prone than simply redirecting the I/O streams before launching the\napplication.  Therefore online rotation is not enabled by default.\n\n\nTimestamping output\n-------------------\nWhen redirecting output, NSSM can prefix each line of output with a\nmillisecond-precision timestamp, for example:\n\n    2016-09-06 10:17:09.451 Pipeline main started\n\nTo enable timestamp prefixing, set AppTimestampLog to a non-zero value.\n\nThe prefix applies to both stdout and stderr.  Prefixing requires\nintercepting the application's I/O in the same way that online rotation\ndoes.  If log rotation and timestamp prefixing are both enabled, the\nrotation will be online.\n\n\nEnvironment variables\n---------------------\nNSSM can replace or append to the managed application's environment.  Two\nmulti-valued string (REG_MULTI_SZ) registry values are recognised under\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters.\n\nAppEnvironment defines a list of environment variables which will override\nthe service's environment.  AppEnvironmentExtra defines a list of\nenvironment variables which will be added to the service's environment.\n\nEach entry in the list should be of the form KEY=VALUE.  It is possible to\nomit the VALUE but the = symbol is mandatory.\n\nEnvironment variables listed in both AppEnvironment and AppEnvironmentExtra\nare subject to normal expansion, so it is possible, for example, to update the\nsystem path by setting \"PATH=C:\\bin;%PATH%\" in AppEnvironmentExtra.  Variables\nare expanded in the order in which they appear, so if you want to include the\nvalue of one variable in another variable you should declare the dependency\nfirst.\n\nBecause variables defined in AppEnvironment override the existing\nenvironment it is not possible to refer to any variables which were previously\ndefined.\n\nFor example, the following AppEnvironment block:\n\n      PATH=C:\\Windows\\System32;C:\\Windows\n      PATH=C:\\bin;%PATH%\n\nWould result in a PATH of \"C:\\bin;C:\\Windows\\System32;C:\\Windows\" as expected.\n\nWhereas the following AppEnvironment block:\n\n      PATH=C:\\bin;%PATH%\n\nWould result in a path containing only C:\\bin and probably cause the\napplication to fail to start.\n\nMost people will want to use AppEnvironmentExtra exclusively.  srvany only\nsupports AppEnvironment.\n\nAs of version 2.25, NSSM parses AppEnvironment and AppEnvironmentExtra\nitself, before reading any other registry values.  As a result it is now\npossible to refer to custom environment variables in Application,\nAppDirectory and other parameters.\n\n\nMerged service environment\n--------------------------\nAll Windows services can be passed additional environment variables by\ncreating a multi-valued string (REG_MULTI_SZ) registry value named\nHLKM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Environment.\n\nThe contents of this environment block will be merged into the system\nenvironment before the service starts.\n\nNote, however, that the merged environment will be sorted alphabetically\nbefore being processed.  This means that in practice you cannot set,\nfor example, DIR=%PROGRAMFILES% in the Environment block because the\nenvironment passed to the service will not have defined %PROGRAMFILES%\nby the time it comes to define %DIR%.  Environment variables defined in\nAppEnvironmentExtra do not suffer from this limitation.\n\nAs of version 2.25, NSSM can get and set the Environment block using\ncommands similar to:\n\n    nssm get \u003cservicename\u003e Environment\n\nIt is worth reiterating that the Environment block is available to all\nWindows services, not just NSSM services.\n\n\nService startup environment\n---------------------------\nThe environment NSSM passes to the application depends on how various\nregistry values are configured.  The following flow describes how the\nenvironment is modified.\n\nBy default:\n    The service inherits the system environment.\n\nIf \u003cservice\u003e\\Environment is defined:\n    The contents of Environment are MERGED into the environment.\n\nIf \u003cservice\u003e\\Parameters\\AppEnvironment is defined:\n    The service inherits the environment specified in AppEnvironment.\n\nIf \u003cservice\u003e\\Parameters\\AppEnvironmentExtra is defined:\n    The contents of AppEnvironmentExtra are APPENDED to the environment.\n\nNote that AppEnvironment overrides the system environment and the\nmerged Environment block.  Note also that AppEnvironmentExtra is\nguaranteed to be appended to the startup environment if it is defined.\n\n\nEvent hooks\n-----------\nNSSM can run user-configurable commands in response to application events.\nThese commands are referred to as \"hooks\" below.\n\nAll hooks are optional.  Any hooks which are run will be launched with the\nenvironment configured for the service.  NSSM will place additional\nvariables into the environment which hooks can query to learn how and why\nthey were called.\n\nHooks are categorised by Event and Action.  Some hooks are run synchronously\nand some are run asynchronously.  Hooks prefixed with an *asterisk are run\nsynchronously.  NSSM will wait for these hooks to complete before continuing\nits work.  Note, however, that ALL hooks are subject to a deadline after which\nthey will be killed, regardless of whether they are run asynchronously\nor not.\n\n  Event: Start - Triggered when the service is requested to start.\n   *Action: Pre - Called before NSSM attempts to launch the application.\n    Action: Post - Called after the application successfully starts.\n\n  Event: Stop - Triggered when the service is requested to stop.\n   *Action: Pre - Called before NSSM attempts to kill the application.\n\n  Event: Exit - Triggered when the application exits.\n   *Action: Post - Called after NSSM has cleaned up the application.\n\n  Event: Rotate - Triggered when online log rotation is requested.\n   *Action: Pre - Called before NSSM rotates logs.\n    Action: Post - Called after NSSM rotates logs.\n\n  Event: Power\n    Action: Change - Called when the system power status has changed.\n    Action: Resume - Called when the system has resumed from standby.\n\nNote that there is no Stop/Post hook.  This is because Exit/Post is called\nwhen the application exits, regardless of whether it did so in response to\na service shutdown request.  Stop/Pre is only called before a graceful\nshutdown attempt.\n\nNSSM sets the environment variable NSSM_HOOK_VERSION to a positive number.\nHooks can check the value of the number to determine which other environment\nvariables are available to them.\n\nIf NSSM_HOOK_VERSION is 1 or greater, these variables are provided:\n\n  NSSM_EXE - Path to NSSM itself.\n  NSSM_CONFIGURATION - Build information for the NSSM executable,\n    eg 64-bit debug.\n  NSSM_VERSION - Version of the NSSM executable.\n  NSSM_BUILD_DATE - Build date of NSSM.\n  NSSM_PID - Process ID of the running NSSM executable.\n  NSSM_DEADLINE - Deadline number of milliseconds after which NSSM will\n    kill the hook if it is still running.\n  NSSM_SERVICE_NAME - Name of the service controlled by NSSM.\n  NSSM_SERVICE_DISPLAYNAME - Display name of the service.\n  NSSM_COMMAND_LINE - Command line used to launch the application.\n  NSSM_APPLICATION_PID - Process ID of the primary application process.\n    May be blank if the process is not running.\n  NSSM_EVENT - Event class triggering the hook.\n  NSSM_ACTION - Event action triggering the hook.\n  NSSM_TRIGGER - Service control triggering the hook.  May be blank if\n    the hook was not triggered by a service control, eg Exit/Post.\n  NSSM_LAST_CONTROL - Last service control handled by NSSM.\n  NSSM_START_REQUESTED_COUNT - Number of times the application was\n    requested to start.\n  NSSM_START_COUNT - Number of times the application successfully started.\n  NSSM_THROTTLE_COUNT - Number of times the application ran for less than\n    the throttle period.  Reset to zero on successful start or when the\n    service is explicitly unpaused.\n  NSSM_EXIT_COUNT - Number of times the application exited.\n  NSSM_EXITCODE - Exit code of the application.  May be blank if the\n    application is still running or has not started yet.\n  NSSM_RUNTIME - Number of milliseconds for which the NSSM executable has\n    been running.\n  NSSM_APPLICATION_RUNTIME - Number of milliseconds for which the\n    application has been running since it was last started.  May be blank\n    if the application has not been started yet.\n\nFuture versions of NSSM may provide more environment variables, in which\ncase NSSM_HOOK_VERSION will be set to a higher number.\n\nHooks are configured by creating string (REG_EXPAND_SZ) values in the\nregistry named after the hook action and placed under\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e\\Parameters\\AppEvents\\\u003cevent\u003e.\n\nFor example the service could be configured to restart when the system\nresumes from standby by setting AppEvents\\Power\\Resume to:\n\n    %NSSM_EXE% restart %NSSM_SERVICE_NAME%\n\nTo set a hook on the command line, use\n\n    nssm set \u003cservicename\u003e AppEvents \u003cevent\u003e/\u003caction\u003e \u003ccommand\u003e\n\nNote that NSSM will abort the startup of the application if a Start/Pre hook\nreturns exit code of 99.\n\nA service will normally run hooks in the following order:\n\n  Start/Pre\n  Start/Post\n  Stop/Pre\n  Exit/Post\n\nIf the application crashes and is restarted by NSSM, the order might be:\n\n  Start/Pre\n  Start/Post\n  Exit/Post\n  Start/Pre\n  Start/Post\n  Stop/Pre\n  Exit/Post\n\n\nIf NSSM is redirecting stdout or stderr it can be configured to redirect\nthe output of any hooks it runs.  Set AppRedirectHooks to 1 to enable\nthat functionality.  A hook can of course redirect its own I/O independently\nof NSSM.\n\n\nManaging services using the GUI\n-------------------------------\nNSSM can edit the settings of existing services with the same GUI that is\nused to install them.  Run\n\n    nssm edit \u003cservicename\u003e\n\nto bring up the GUI.\n\nNSSM offers limited editing capabilities for services other than those which\nrun NSSM itself.  When NSSM is asked to edit a service which does not have\nthe App* registry settings described above, the GUI will allow editing only\nsystem settings such as the service display name and description.\n\n\nManaging services using the command line\n----------------------------------------\nNSSM can retrieve or set individual service parameters from the command line.\nIn general the syntax is as follows, though see below for exceptions.\n\n    nssm get \u003cservicename\u003e \u003cparameter\u003e\n\n    nssm set \u003cservicename\u003e \u003cparameter\u003e \u003cvalue\u003e\n\nParameters can also be reset to their default values.\n\n    nssm reset \u003cservicename\u003e \u003cparameter\u003e\n\nThe parameter names recognised by NSSM are the same as the registry entry\nnames described above, eg AppDirectory.\n\nNSSM offers limited editing capabilities for Services other than those which\nrun NSSM itself.  The parameters recognised are as follows:\n\n  Description: Service description.\n  DisplayName: Service display name.\n  Environment: Service merged environment.\n  ImagePath: Path to the service executable.\n  ObjectName: User account which runs the service.\n  Name: Service key name.\n  Start: Service startup type.\n  Type: Service type.\n\nThese correspond to the registry values under the service's key\nHKLM\\SYSTEM\\CurrentControlSet\\Services\\\u003cservice\u003e.\n\n\nNote that NSSM will concatenate all arguments passed on the command line\nwith spaces to form the value to set.  Thus the following two invocations\nwould have the same effect.\n\n    nssm set \u003cservicename\u003e Description \"NSSM managed service\"\n\n    nssm set \u003cservicename\u003e Description NSSM managed service\n\n\nNon-standard parameters\n-----------------------\nThe AppEnvironment, AppEnvironmentExtra and Environment parameters\nrecognise an additional argument when querying the environment.  The\nfollowing syntax will print all extra environment variables configured\nfor a service\n\n    nssm get \u003cservicename\u003e AppEnvironmentExtra\n\nwhereas the syntax below will print only the value of the CLASSPATH\nvariable if it is configured in the environment block, or the empty string\nif it is not configured.\n\n    nssm get \u003cservicename\u003e AppEnvironmentExtra CLASSPATH\n\nWhen setting an environment block, each variable should be specified as a\nKEY=VALUE pair in separate command line arguments.  For example:\n\n    nssm set \u003cservicename\u003e AppEnvironment CLASSPATH=C:\\Classes TEMP=C:\\Temp\n\nAlternatively the KEY can be prefixed with a + or - symbol to respectively\nadd or remove a pair from the block.\n\nThe following two lines set CLASSPATH and TEMP:\n\n    nssm set \u003cservicename\u003e AppEnvironment CLASSPATH=C:\\Classes\n    nssm set \u003cservicename\u003e AppEnvironment +TEMP=C:\\Temp\n\nIf the key is already present, specifying +KEY will override the value\nwhile preserving the order of keys:\n\n    nssm set \u003cservicename\u003e AppEnvironment +CLASSPATH=C:\\NewClasses\n\nThe following syntax removes a single variable from the block while\nleaving any other variables in place.\n\n    nssm set \u003cservicename\u003e AppEnvironment -TEMP\n\nSpecifying -KEY=VALUE will remove the variable only if the existing\nvalue matches.\n\nThe following syntax would not remove TEMP=C:\\Temp\n\n    nssm set \u003cservicename\u003e AppEnvironment -TEMP=C:\\Work\\Temporary\n\nThe + and - symbols are valid characters in environment variables.\nThe syntax :KEY=VALUE is equivalent to KEY=VALUE and can be used to\nset variables which start with +/- or to explicitly reset the block in\na script:\n\n    nssm set \u003cservicename\u003e AppEnvironment :CLASSPATH=C:\\Classes\n    nssm set \u003cservicename\u003e AppEnvironment +TEMP=C:\\Temp\n\n\nThe AppExit parameter requires an additional argument specifying the exit\ncode to get or set.  The default action can be specified with the string\nDefault.\n\nFor example, to get the default exit action for a service you should run\n\n    nssm get \u003cservicename\u003e AppExit Default\n\nTo get the exit action when the application exits with exit code 2, run\n\n    nssm get \u003cservicename\u003e AppExit 2\n\nNote that if no explicit action is configured for a specified exit code,\nNSSM will print the default exit action.\n\nTo set configure the service to stop when the application exits with an\nexit code of 2, run\n\n    nssm set \u003cservicename\u003e AppExit 2 Exit\n\n\nThe AppPriority parameter is used to set the priority class of the\nmanaged application.  Valid priorities are as follows:\n\n  REALTIME_PRIORITY_CLASS\n  HIGH_PRIORITY_CLASS\n  ABOVE_NORMAL_PRIORITY_CLASS\n  NORMAL_PRIORITY_CLASS\n  BELOW_NORMAL_PRIORITY_CLASS\n  IDLE_PRIORITY_CLASS\n\n\nThe DependOnGroup and DependOnService parameters are used to query or set\nthe dependencies for the service.  When setting dependencies, each service\nor service group (preceded with the + symbol) should be specified in\nseparate command line arguments.  For example:\n\n    nssm set \u003cservicename\u003e DependOnService RpcSs LanmanWorkstation\n\nAlternatively the dependency name can be prefixed with a + or - symbol to\nrespectively add or remove a dependency.\n\nThe following two lines set dependencies on RpcSs and LanmanWorkstation:\n\n    nssm set \u003cservicename\u003e DependOnService RpcSs\n    nssm set \u003cservicename\u003e DependOnService +LanmanWorkstation\n\nThe follwing syntax removes the dependency on RpcSs:\n\n    nssm set \u003cservicename\u003e DependOnService -RpcSs\n\nService groups should, strictly speaking, be prefixed with the + symbol.\nTo specify a single dependency on a group, the + symbol can be prefixed\nwith the : symbol.\n\nThe following lines are equivalent, and each set a dependency ONLY on\nNetBIOSGroup:\n\n    nssm set \u003cservicename\u003e DependOnGroup NetBIOSGroup\n    nssm set \u003cservicename\u003e DependOnGroup :NetBIOSGroup\n    nssm set \u003cservicename\u003e DependOnGroup :+NetBIOSGroup\n\nWhereas these lines add to any existing dependencies:\n\n    nssm set \u003cservicename\u003e DependOnGroup +NetBIOSGroup\n    nssm set \u003cservicename\u003e DependOnGroup ++NetBIOSGroup\n\n\nThe Name parameter can only be queried, not set.  It returns the service's\nregistry key name.  This may be useful to know if you take advantage of\nthe fact that you can substitute the service's display name anywhere where\nthe syntax calls for \u003cservicename\u003e.\n\n\nThe ObjectName parameter requires an additional argument only when setting\na username.  The additional argument is the password of the user.\n\nTo retrieve the username, run\n\n    nssm get \u003cservicename\u003e ObjectName\n\nTo set the username and password, run\n\n    nssm set \u003cservicename\u003e ObjectName \u003cusername\u003e \u003cpassword\u003e\n\nNote that the rules of argument concatenation still apply.  The following\ninvocation is valid and will have the expected effect.\n\n    nssm set \u003cservicename\u003e ObjectName \u003cusername\u003e correct horse battery staple\n\nThe following well-known usernames do not need a password.  The password\nparameter can be omitted when using them:\n\n  \"LocalSystem\" aka \"System\" aka \"NT Authority\\System\"\n  \"LocalService\" aka \"Local Service\" aka \"NT Authority\\Local Service\"\n  \"NetworkService\" aka \"Network Service\" aka \"NT Authority\\Network Service\"\n  Virtual service account \"NT Service\\\u003cservicename\u003e\"\n\n\nThe Start parameter is used to query or set the startup type of the service.\nValid service startup types are as follows:\n\n  SERVICE_AUTO_START: Automatic startup at boot.\n  SERVICE_DELAYED_START: Delayed startup at boot.\n  SERVICE_DEMAND_START: Manual service startup.\n  SERVICE_DISABLED: The service is disabled.\n\nNote that SERVICE_DELAYED_START is not supported on versions of Windows prior\nto Vista.  NSSM will set the service to automatic startup if delayed start is\nunavailable.\n\n\nThe Type parameter is used to query or set the service type.  NSSM recognises\nall currently documented service types but will only allow setting one of two\ntypes:\n\n  SERVICE_WIN32_OWN_PROCESS: A standalone service.  This is the default.\n  SERVICE_INTERACTIVE_PROCESS: A service which can interact with the desktop.\n\nNote that a service may only be configured as interactive if it runs under\nthe LocalSystem account.  The safe way to configure an interactive service\nis in two stages as follows.\n\n    nssm reset \u003cservicename\u003e ObjectName\n    nssm set \u003cservicename\u003e Type SERVICE_INTERACTIVE_PROCESS\n\n\nControlling services using the command line\n-------------------------------------------\nNSSM offers rudimentary service control features.\n\n    nssm start \u003cservicename\u003e\n\n    nssm restart \u003cservicename\u003e\n\n    nssm stop \u003cservicename\u003e\n\n    nssm status \u003cservicename\u003e\n\n    nssm statuscode \u003cservicename\u003e\n\nThe output of \"nssm status\" and \"nssm statuscode\" is a string\nrepresenting the service state, eg SERVICE_RUNNING.\n\nThe exit code of \"nssm status\" will be 0 if the status was\nsuccesfully retrieved.  If the exit code is not zero there was\nan error.\n\nThe exit code of \"nssm statuscode\" will be the numeric value\nof the service state, eg 4 for SERVICE_RUNNING.  Zero is not a\nvalid service state code.  If the exit code is zero there was\nan error.\n\n\nRemoving services using the GUI\n-------------------------------\nNSSM can also remove services.  Run\n\n    nssm remove \u003cservicename\u003e\n\nto remove a service.  You will prompted for confirmation before the service \nis removed.  Try not to remove essential system services...\n\n\nRemoving service using the command line\n---------------------------------------\nTo remove a service without confirmation from the GUI, run\n\n    nssm remove \u003cservicename\u003e confirm\n\nTry not to remove essential system services...\n\n\nLogging\n-------\nNSSM logs to the Windows event log.  It registers itself as an event log source\nand uses unique event IDs for each type of message it logs.  New versions may\nadd event types but existing event IDs will never be changed.\n\nBecause of the way NSSM registers itself you should be aware that you may not\nbe able to replace the NSSM binary if you have the event viewer open and that\nrunning multiple instances of NSSM from different locations may be confusing if\nthey are not all the same version.\n\n\nListing managed services\n------------------------\nThe following command will print the names of all services managed by NSSM:\n\n    nssm list\n\nTo see all services on the system, not just NSSM's, use list all:\n\n    nssm list all\n\n\nShowing processes started by a service\n--------------------------------------\nThe following command will print the process ID and executable path of\nprocesses started by a given service:\n\n    nssm processes \u003cservicename\u003e\n\nNote that if 32-bit NSSM is run on a 64-bit system running an older version of\nWindows than Vista it will not be able to query the paths of 64-bit processes.\n\n\nExporting service configuration\n-------------------------------\nNSSM can dump commands which would recreate the configuration of a service.\nThe output can be pasted into a batch script to back up the service or\ntransfer to another computer.\n\n    nssm dump \u003cservicename\u003e\n\nBecause the service configuration may contain characters which need to be\nquoted or escaped from the command prompt, NSSM tries hard to produce\noutput which will work correctly when run as a script, by adding quotes\nand caret escapes as appropriate.\n\nTo facilitate copying a service, the dump command accepts a second\nargument which specifies the name of the service to be used in the output.\n\n    nssm dump \u003cservicename\u003e \u003cnewname\u003e\n\nLines in the dump will reference the \u003cnewname\u003e service while showing the\nconfiguration of \u003cservicename\u003e.\n\n\nExample usage\n-------------\nTo install an Unreal Tournament server:\n\n    nssm install UT2004 c:\\games\\ut2004\\system\\ucc.exe server\n\nTo run the server as the \"games\" user:\n\n    nssm set UT2004 ObjectName games password\n\nTo configure the server to log to a file:\n\n    nssm set UT2004 AppStdout c:\\games\\ut2004\\service.log\n\nTo restrict the server to a single CPU:\n\n    nssm set UT2004 AppAffinity 0\n\nTo remove the server:\n\n    nssm remove UT2004 confirm\n\nTo find out the service name of a service with a display name:\n\n    nssm get \"Background Intelligent Transfer Service\" Name\n\n\nBuilding NSSM from source\n-------------------------\nNSSM is known to compile with Visual Studio 2008 and later.  Older Visual\nStudio releases may or may not work if you install an appropriate SDK and\nedit the nssm.vcproj and nssm.sln files to set a lower version number.\nThey are known not to work with default settings.\n\nNSSM will also compile with Visual Studio 2010 but the resulting executable\nwill not run on versions of Windows older than XP SP2.  If you require\ncompatiblity with older Windows releases you should change the Platform\nToolset to v90 in the General section of the project's Configuration\nProperties.\n\n\nCredits\n-------\nThanks to Bernard Loh for finding a bug with service recovery.\nThanks to Benjamin Mayrargue (www.softlion.com) for adding 64-bit support.\nThanks to Joel Reingold for spotting a command line truncation bug.\nThanks to Arve Knudsen for spotting that child processes of the monitored\napplication could be left running on service shutdown, and that a missing\nregistry value for AppDirectory confused NSSM.\nThanks to Peter Wagemans and Laszlo Keresztfalvi for suggesting throttling\nrestarts.\nThanks to Eugene Lifshitz for finding an edge case in CreateProcess() and for\nadvising how to build messages.mc correctly in paths containing spaces.\nThanks to Rob Sharp for pointing out that NSSM did not respect the\nAppEnvironment registry value used by srvany.\nThanks to Szymon Nowak for help with Windows 2000 compatibility.\nThanks to François-Régis Tardy and Gildas le Nadan for French translation.\nThanks to Emilio Frini for spotting that French was inadvertently set as\nthe default language when the user's display language was not translated.\nThanks to Riccardo Gusmeroli and Marco Certelli for Italian translation.\nThanks to Eric Cheldelin for the inspiration to generate a Control-C event\non shutdown.\nThanks to Brian Baxter for suggesting how to escape quotes from the command\nprompt.\nThanks to Russ Holmann for suggesting that the shutdown timeout be configurable.\nThanks to Paul Spause for spotting a bug with default registry entries.\nThanks to BUGHUNTER for spotting more GUI bugs.\nThanks to Doug Watson for suggesting file rotation.\nThanks to Арслан Сайдуганов for suggesting setting process priority.\nThanks to Robert Middleton for suggestion and draft implementation of process\naffinity support.\nThanks to Andrew RedzMax for suggesting an unconditional restart delay.\nThanks to Bryan Senseman for noticing that applications with redirected stdout\nand/or stderr which attempt to read from stdin would fail.\nThanks to Czenda Czendov for help with Visual Studio 2013 and Server 2012R2.\nThanks to Alessandro Gherardi for reporting and draft fix of the bug whereby\nthe second restart of the application would have a corrupted environment.\nThanks to Hadrien Kohl for suggesting to disable the console window's menu.\nThanks to Allen Vailliencourt for noticing bugs with configuring the service to\nrun under a local user account.\nThanks to Sam Townsend for noticing a regression with TerminateProcess().\nThanks to Barrett Lewis for suggesting the option to skip terminating the\napplication's child processes.\nThanks to Miguel Angel Terrón for suggesting copy/truncate rotation.\nThanks to Yuriy Lesiuk for suggesting setting the environment before querying\nthe registry for parameters.\nThanks to Gerald Haider for noticing that installing a service with NSSM in a\npath containing spaces was technically a security vulnerability.\nThanks to Scott Ware for reporting a crash saving the environment on XP 32-bit.\nThanks to Stefan and Michael Scherer for reporting a bug writing the event messages source.\nThanks to Paul Baxter for help with Visual Studio 2015.\nThanks to Mathias Breiner for help with Visual Studio and some registry fixes.\nThanks to David Bremner for general tidyups.\nThanks to Nabil Redmann for suggesting redirecting hooks' output.\nThanks to Bader Aldurai for suggesting the process tree.\nThanks to Christian Long for suggesting virtual accounts.\nThanks to Marcin Lewandowski for spotting a bug appending to large files.\nThanks to Nicolas Ducrocq for suggesting timestamping redirected output.\nThanks to Meang Akira Tanaka for suggestion and initial implementation of\nthe statuscode command.\nThanks to Kirill Kovalenko for reporting a crash with NANO server.\nThanks to Connor Reynolds for spotting a potential buffer overflow.\nThanks to foi for spotting a hang with 64 cores.\n\nLicence\n-------\nNSSM is public domain.  You may unconditionally use it and/or its source code \nfor any purpose you wish.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkxce%2Fnssm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkxce%2Fnssm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkxce%2Fnssm/lists"}