如何将参数传递给 Inno Setup 命令行编译器?
IS 新闻组建议使用 /D
但使用版本 5.2.3 附带的 iscc.exe 时出现“未知选项:”错误。
那么在脚本中,如何使用命令行参数的值呢?
It was suggested in the IS newsgroup to use /D<variable>=<value>
but using the iscc.exe that came with version 5.2.3 I get an "Unknown option:" error.
Then in the script, how do you use the value of the command line parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 MicSim 所说,你确实需要预处理器。 它包含在最新的 ISPack 中。 安装后,iscc 支持
/D
。然后,您可以使用如下定义的值(假设您已完成
/DVERSION_NAME=1.23
):You do, as MicSim says, need the preprocessor. It's included in the latest ISPack. Once it's installed, iscc supports
/D
.You can then use the values defined like this (assuming you'd done
/DVERSION_NAME=1.23
):来自 Inno Setup 帮助文件:
“额外参数”包括
/d
选项。From the Inno Setup helpfile:
The "extra parameters" include the
/d
option.@Steven Dunn
的回答要点是用另一层抽象来解决问题:不要直接从终端调用iscc your_script.iss
,而是调用your_script.ps1 -YourVar "value"
,处理开关,将#define
写入.iss
文件,然后然后使用iscc
编译它。 这没有得到很好的阐述,而且我认为显示的用于解析命令行参数的函数没有增加太多价值。 不过,我还是在应得的地方给予赞扬。正如
@jdigital
提到的,ISPP
有/d
开关,但是ISPP
不能直接从终端(据我所知)。 因此,@Steven Dunn 暗示的辅助脚本方法之类的东西是必要的。您可以通过向现有
.iss
脚本添加占位符,然后相应地覆盖它们来实现此目的:.iss
模板.ps1
脚本示例终端用法
或如果您愿意,可以从
.ps1
脚本中运行iscc
步骤。The point of the answer by
@Steven Dunn
is to solve the problem with another layer of abstraction: instead of callingiscc your_script.iss
directly from the terminal, callyour_script.ps1 -YourVar "value"
, process the switch, write a#define
to the.iss
file, and then compile it withiscc
. This was not articulated well and I don't think the function shown to parse command line arguments added much value. However, I'm giving credit where credit is due.As
@jdigital
mentioned,ISPP
has the/d
switch, butISPP
can't be run directly from the terminal (AFAIK). Hence, something like a secondary scripted approach hinted at by@Steven Dunn
is necessary.You can achieve this by adding placeholders to an existing
.iss
script and then overwrite them accordingly:.iss
Template.ps1
ScriptExample Terminal Usage
or run the
iscc
step from within your.ps1
script, if you prefer./D
命令行参数对我来说非常有用。 如果您对语法感到困惑,我建议您调用iscc \?
来查看帮助菜单,因为它在这里非常有用。以下是我们创建安装程序的方法:
然后在 ISS 中您可以像任何其他变量一样访问:
The
/D
command line arg worked great for me. If you are struggling with the syntax I recommend just invokingiscc \?
to see the help menu since it is pretty useful here.Here is how we create our installer:
Then within the ISS you access like any other var:
如果要在 Inno Setup 中解析来自
[Code]
的命令行参数,请使用与此类似的方法。 只需从命令行调用 inno 脚本,如下所示:然后您可以在任何需要的地方调用
GetCommandLineParam
://================ ===================================================
希望这可以帮助...
If you want to parse command line arguments from
[Code]
in Inno Setup, then use a method similar to this. Just call the inno script from the command line as follows:Then you can call the
GetCommandLineParam
like this wherever you need it://==================================================================
Hope this helps...