How to handle path with spaces in Inno Setup?

只愿长相守 提交于 2021-01-23 01:47:30

问题


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:


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



来源:https://stackoverflow.com/questions/47281316/how-to-handle-path-with-spaces-in-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!