如何在Inno Setup中使用空格处理路径? [英] How to handle path with spaces in Inno Setup?

查看:53
本文介绍了如何在Inno Setup中使用空格处理路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Inno Setup安装程序时,我想允许路径带有空格(例如,程序文件).但是带有空格的路径会使我的已安装服务崩溃.

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.

Inno Setup文件如下:

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";是将Java应用程序作为Windows服务执行的服务包装器.

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

关键部分是这一行:

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

根据此问题/答案中的建议,我试图使用双双引号,但这无济于事,该服务仍在崩溃.如果我将 DefaultDirName 更改为没有空格的路径,那么一切都会按预期进行.

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?

推荐答案

问题是Inno Setup和nssm的组合,它们都在转义双引号和双引号.这使得必须使用多个双引号.

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.

解决方案:

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

请参见 nssm文档报价问题"部分.

See nssm documentation section "Quoting issues".

这篇关于如何在Inno Setup中使用空格处理路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆