我需要在“文件”部分中在编译时(例如在运行安装时)在命令行上设置变量的路径
compil32 "script.iss" -CmdPath "D:\Samples"
script.iss:
#define DefPath "D:\Install"
[Files]
Source: {param:CmdPath|DefPath}\Install\App.exe; DestDir: {app};
您可以通过使用ISCC编译器通过/D
参数传递路径来构建您的设置。这将为您的脚本声明一个公共的#define
。由于#define
可以由脚本重新声明,因此您需要确保对其想要的默认值进行条件声明。例如:
#ifndef SrcPath
#define SrcPath "C:\DefaultPath\"
#endif
[Files]
Source: {#SrcPath}App.exe; DestDir: {app}
然后以这种方式构建设置将使用脚本中的#define
:
ISCC.exe Script.iss
虽然以此方式进行构建,但将使用传递的参数值声明的#define
:
ISCC.exe Script.iss /DSrcPath="C:\AnotherPath\"