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?
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".