在 Inno Setup 编译器中运行 [Code] 或 PowerShell 脚本

use*_*916 5 powershell inno-setup pascalscript

[Code]在生成安装可执行文件之前,有没有办法在 Inno Setup 编译器中运行过程或 PowerShell 脚本?

Mar*_*ryl 4

如果您解释一下运行代码的目的,您可能会得到更好的答案。反正...


一种方法是从批处理文件在命令行上编译脚本

powershell -file precompile.ps1

ISCC.exe setup.iss

powershell -file postcompile.ps1
Run Code Online (Sandbox Code Playgroud)

(或者您可以ISCC.exe从 PowerShell 脚本本身调用)


在编译之前运行某些脚本的另一种方法是使用Exec预处理器函数

#expr Exec("precompile.bat")
Run Code Online (Sandbox Code Playgroud)

或者

#expr Exec("powershell -file precompile.ps1")
Run Code Online (Sandbox Code Playgroud)

另请参阅编译 Inno Setup 脚本时是否可以调用批处理文件?


如果您需要 GUI 解决方案,可以使用ISTool,它是一个 Inno Setup 扩展,它直接支持预编译和后编译“步骤”。但不幸的是这个项目不再维护了。您也许可以将其更新到最新的 Inno Setup 版本,因为它是开源的。