3

I'm trying to use the Non-Sucking Service Manager (NSSM) to create a service. Unfortunately, for whatever reason, NSSM won't play ball.

I'm trying to install the service using the following command:

nssm install "My Service" "C:\Program Files\Vendor\bin\windows\service-start.bat"

The service is successfully created. However, when I go to Services and Right-Click on "My Service" and view the properties the "Path to executable" field is set to the path of NSSM itself. In this case, 'C:\Program Files\nssm-2.24\win64\nssm.exe'.

I've attempted to change this using the following command:

nssm set "My Service" AppDirectory "C:\Program Files\Vendor\bin\windows\service-start.bat"

This doesn't make any difference and the executable path remains the same.

I'm trying to do this on Windows Server 2012 R2.

TylerH
  • 20,799
  • 66
  • 75
  • 101

2 Answers2

3

As CodeCaster mentioned, the 'Path to Executable' is correctly referring to nssm. Since nssm is a wrapper, you technically tell nssm to manage your service.

If you want to verify if your installed service actually refers to your service, you will need to check that in nssm instead. You can do so with below command:

nssm edit <servicename>

Here you can see what is configured for your service and you can do some extra configuration here as well. I hope that clarifies things a bit.

Gambit
  • 203
  • 1
  • 2
  • 12
0

NSSM is a wrapper which responds to SCM commands... which a batch file won't.

When registering the service, ...service-start.bat is configured as a commandline arguments to the NSSM executable.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • Hi, thanks for getting back to me but that doesn't really address the issue encountered. NSSM ignores the path to the executable I set irrespective of the file type. I've tried with .bat, .exe. and .cmd. – automation1002 Feb 05 '18 at 10:51
  • Then you're not asking the question you want answered. The _"path to the executable"_ is the path to the service executable. In this case, this is NSSM's path, which is correct. – CodeCaster Feb 05 '18 at 11:37
  • You're [probably just looking for `%0`](https://stackoverflow.com/questions/17063947/get-current-batchfile-directory) to get the batch file's location. – CodeCaster Feb 05 '18 at 11:48