【问题标题】:Use INI file to determine destination path while installing the exe安装 exe 时使用 INI 文件确定目标路径
【发布时间】:2021-06-20 19:34:48
【问题描述】:

我需要在两个不同的目标文件夹中安装安装程序(通过 inno setup 创建)。

我的目标是在安装时使用 ini 文件来确定目标目录。

Setup.ini 文件

[Settings]
#======================================================================
DestDir=C:\\Software\\Path1
#======================================================================

Inno 设置文件

#define DestinationDir ReadIni("Setup.ini", "Settings", "DestDir", "")

[Files]
Source: "D:\Publish\MyService.exe";                 DestDir: "{#DestDir}";    Flags: ignoreversion

[Run]
Filename: "{#DestDir}\MyService.exe";        Parameters: "-i -name MyService-display ""My Service""";       StatusMsg: "Installing my service";

我将安装程序文件 (setup.exe) 与 .ini 文件(设置为 path1)一起复制到服务器并运行安装程序。我希望将 myService.exe 文件复制到 Path1(“C:\Software\Path1”)中。

然后我将.ini文件更改为以下并重新运行安装程序。我希望将 myService.exe 文件复制到 Path2(“C:\Software\Path2”)中。

[Settings]
#======================================================================
DestDir=C:\\Software\\Path2
#======================================================================

但是,这根本不起作用。似乎只有当我们通过 inno setup 创建安装程序时才能引用 ini 文件,而不是在执行安装程序时。有什么建议可以实现吗?

【问题讨论】:

  • 路径名中不需要\\。一个 \ 就足够了。

标签: installation inno-setup ini


【解决方案1】:

您的代码使用的是preprocessor。预处理器在编译时评估。它对运行/安装时间没有影响。


Inno Setup 具有指定目标路径的内置功能。您可以使用command-line switch /DIR= 指定路径:

setup.exe /DIR=C:\Software\Path1

另一种选择是使用特殊的 INI 文件,如下所示,使用 /LOADINF switch

[Setup]
Dir=C:\Software\Path1

一个相关问题:Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation

【讨论】:

    猜你喜欢
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多