如何通过Inno Setup在预处理器函数中使用预处理器变量

时间:2020-02-20 13:12:01

标签: windows inno-setup

我尝试使用Exec()预处理程序功能运行PowerShell脚本,但是我需要向其传递两个参数。我怎样才能做到这一点?以下代码段无效。

#define PSScript  SourcePath + "\\UpdateJson.ps1"
#define ConfigPath  SourcePath + "\\ClientConfig.json"
#expr Exec("PowerShell -NoProfile -ExecutionPolicy Bypass -File {#PSScript} {#ConfigPath} Str({#BuildNumber})")

谢谢!

1 个答案:

答案 0 :(得分:1)

使用+运算符,就像在PSScriptConfigPath声明中已经使用它一样。

此外,Exec function分别需要参数。

其他内容:
1)如果路径中包含空格,则应将其包装为双引号。
2)默认情况下,Inno Setup预处理程序不需要转义反斜杠。

#define PSScript  SourcePath + "\UpdateJson.ps1"
#define ConfigPath  SourcePath + "\ClientConfig.json"

#expr Exec("PowerShell", \
           "-NoProfile -ExecutionPolicy Bypass -File """ + PSScript + """ " + \
               """" + ConfigPath + """ " + Str(BuildNumber))