引用安装路径的子文件夹而不在整个脚本中重复名称

Refer to a subfolder of an installation path without repeating the name throughout the script

当您在 Inno Setup 安装程序中提供文件夹位置时,它会将其设置为常量 {app}。如果文件夹位置指定为 C:\Program Files\Test1,这会将其设置为 {app} 变量。当用户给出这个路径时,是否可以像这样添加到{app}变量C:\Program Files\Test1\MyApp-3.1

如果用户将文件夹位置指定为 C:\Program Files\Test1 并单击 下一步 按钮,则应将其更改为 C:\Program Files\Test1\MyApp-3.1。这可能吗?

根据 this page {app} 是目录常量。

我在以下部分中将许多文件设置为 运行,

[Icons]
[Run]
[InstallDelete]
[UninstallRun]

例如,{app}\Run.exe。我需要将 {app} 更改为 C:\Program Files\Test1\MyApp-3.1,而不是将 {app}\Run.exe 更改为 {app}\Program\Run.exe

我有一个程序总是需要从文件夹结构 MyApp-3.1\Run.exe 运行。如果用户select安装文件夹为C:\Program Files\Test1则文件夹需要设置为C:\Program Files\Test1\MyApp-3.1。简单的方法是创建文件夹 MyApp-3.1,其中包含 Run.exe,并将该文件夹添加到安装程序。因此它将安装 MyApp-3.1 文件夹。问题是如果文件夹名称更改为 MyApp-3.2 那么代码中必须有很多更改。

问题是单击文件夹 selection 对话框中的下一步按钮后可以设置 {app} 变量吗?

看来您确实需要 preprocessor macro:

#define DestPath "{app}\MyApp-3.1"

[Files]
Source: "Run.exe"; DestDir: "{#DestPath}"
Source: "Otherfile"; DestDir: "{#DestPath}"

[Icons]
Name: "{commondesktop}\My Program"; Filename: "{#DestPath}\Run.exe"; \
    WorkingDir: "{#DestPath}"

[Run]
Filename: "{#DestPath}\Run.exe"; Parameters: "/install"

[UninstallRun]
Filename: "{#DestPath}\Run.exe"; Parameters: "/uninstall"

如果您需要更改子文件夹名称,只需更改 DestPath 定义:

#define DestPath "{app}\MyApp-3.2"