4
votes

I want to allow paths with spaces (for example program files) when installing my program with Inno Setup. However paths with spaces let my installed service crash.

The Inno Setup file looks like this:

[Setup]
AppName=Demo
DefaultDirName={pf}\demo

[Files]
Source: "bin\nssm.exe"; DestDir: "{app}"
Source: "bin\jdk1.8.0_152\jre\*"; DestDir: "{app}\jre"; Flags: recursesubdirs
Source: "build\libs\demo.jar"; DestDir: "{app}"

[Run]
Filename: "{app}\nssm.exe"; \
    Parameters: "install demo ""{app}\jre\bin\java.exe"" -jar ""{app}\demo.jar"""
Filename: "{app}\nssm.exe"; Parameters: "start demo"

"nssm.exe" is a service wrapper to execute a java application as a windows service.

The critical part is this line:

Filename: "{app}\nssm.exe"; \
     Parameters: "install demo ""{app}\jre\bin\java.exe"" -jar ""{app}\demo.jar"""

As suggested in this question/answer, I tried to use double double quotes, but this doesn't help, the service is still crashing. If I change DefaultDirName to a path without spaces everything works as expected.

DefaultDirName=c:\demo

How do I have to handle paths with spaces?

1
Your Inno Setup code it correct. Isn't the problem with your application (nssm.exe or demo.jar), rather than with the installer? Can you even run "C:\Program Files\Demo\nssm.exe" install demo "C:\Program Files\Demo\jre\bin\java.exe" -jar "C:\Program Files\Demo\demo.jar" from Windows command-line?Martin Prikryl
Thanks, for the hint. I tried it from the command line, but with relative paths, where it worked. The actual problem was that Inno Setup and nssm both use double quote with double quote escaping (see solution below).deamon

1 Answers

4
votes

The problem was the combination of Inno Setup and nssm, which both are escaping double quotes with double quotes. That makes multiple double quotes necessary.

Solution:

Filename: "{app}\nssm.exe"; Parameters: "install demo ""{app}\jre\bin\java.exe"" -jar """"""{app}\demo.jar"""""""

See nssm documentation section "Quoting issues".