10

I am trying to use Inno Setup to install a Windows service as a JAR file running under NSSM (Non-Sucking Service Manager)

nssm install JarService java -jar service.jar
nssm start JarService

ends up putting my service in the "Paused" state, and it doesn't ever seem to get started.

Since the location of java.exe can change with updates, I want to be able to run the service without having the explicit path to java.exe, how can I launch the java service without an explicit path in NSSM?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
mcarr
  • 121
  • 1
  • 1
  • 8

3 Answers3

10

I had to do something quite similar just last week. When I replace "java" with the full path to java.exe, I can get a service to run, so:

nssm install JarService FullPath/java.exe -jar service.jar

should work. I don't think NSSM searches the path for its application.

rkh
  • 1,761
  • 1
  • 20
  • 30
  • getting the error when I start the service "windows could not start the service, if its a non Microsoft service refer to service specific error code 3" – Waqas Mar 01 '20 at 10:52
  • I am also getting the same , any solutions how to resolve it – Tanish Gupta Apr 26 '23 at 06:16
2

On Windows 2012 R2 OS, I used:

nssm install MyServiceName "C:\Program Files\MyServiceName\start.bat"

Then in the batch file, start.bat, I have:

java -cp "C:\Program Files\MyServiceName\MyServiceName.jar" com.package.MyServiceMainClass
Brad Rippe
  • 3,405
  • 1
  • 18
  • 20
1

I had to create a powershell script to run the java service:

java.exe -jar service.jar

Then, I reference the full path to powershell in Inno Setup's [Run] section:

Filename: "{app}\nssm.exe"; Parameters: "install ""{#MyAppName}"" ""{sys}\WindowsPowerShell\v1.0\powershell.exe"" ""-ExecutionPolicy Unrestricted -File {app}\runservice.ps1"""; Flags: runhidden 

As long as powershell doesn't move, this should work.

mcarr
  • 121
  • 1
  • 1
  • 8