我需要在两个不同的目标文件夹中安装一个安装程序(通过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文件,而不能在执行安装程序时引用。如何实现这一点有什么建议吗?
发布于 2021-03-24 14:50:02
您的代码正在使用preprocessor。预处理器在编译时进行计算。它对运行/安装时间没有影响。
Inno安装程序具有用于指定目标路径的内置功能。您可以使用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
https://stackoverflow.com/questions/66775153
复制相似问题