WiX:如果特定可执行文件不在 PATH 中,则中止安装
我目前正在使用 WiX 打包需要 Java 才能运行的软件。因此,我想在安装过程中检查 java.exe
是否位于 PATH
中,如果找不到则中止。 http://sourceforge.net/mailarchive/message.php?msg_id=23451655<中的解决方案/a> 接近我的需求,但我不想搜索注册表,而是想在 PATH
变量中的目录中查找依赖项。
使用 WiX 可以轻松实现这一点吗?如果没有,是否可以根据自定义操作的返回值设置属性的值。然后,我可以编写一个批处理脚本来查找 Java 并相应地设置
的属性。
I'm currently packaging software with WiX that needs Java to run. Therefore I'd like to check during installation if java.exe
is somewhere in the PATH
and abort if it could not be found. The solution in http://sourceforge.net/mailarchive/message.php?msg_id=23451655 comes close to my needs, but instead of searching the registry, I'd like to look for the dependency in the directories in the PATH
variable.
Is this easily possible with WiX? If not, is it possible to set the value of a property based on the return value of a custom action. I could then write a batch script that looks for Java and sets the property for the <Condition>
accordingly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 Yan 的回答,我已经实现了这样的功能:
我的 WiX 源包含:
并且
CustomActions.js
包含此功能:而不是在
PATH
我正在通过尝试执行 Java 来检查 Java 是否已安装。如果 Java 无法执行,Exec
会抛出异常,并且JAVA_IS_INSTALLED
永远不会设置。Based on Yan's answer I've implemented this functionality like this:
My WiX source contains:
And the
CustomActions.js
contains this function:Instead of looking for
java.exe
in thePATH
I'm checking if Java is installed by trying to execute it. If Java cannot be executedExec
throws an exception andJAVA_IS_INSTALLED
is never set.我将编写一个立即自定义操作,该操作将执行以下操作:
[%PATH]
语法;
拆分来解析它,迭代并查找有问题的目录java.exe
存在,JAVA_IS_INSTALLED
属性设置为1
,否则根本不设置。这可以通过使用 DTF(WiX 工具集提供的框架)的session["JAVA_IS_INSTALLED"] = 1
来完成,
元素以及JAVA_IS_INSTALLED< /code> 属性
注意:自定义操作应在 LaunchConditions 操作之前安排,并且应驻留在两个序列中(InstallUISequence 和 InstallExecuteSequence)
I would author an immediate custom action which would do the following:
[%PATH]
syntax;
, iterating and finding the directory in questionjava.exe
is present thereJAVA_IS_INSTALLED
property to1
in case it is there, otherwise don't set at all. This can be done assession["JAVA_IS_INSTALLED"] = 1
with DTF (a framework supplied with WiX Toolset)<Condition>
element withJAVA_IS_INSTALLED
propertyNOTE: the custom action should be scheduled before LaunchConditions action and should reside in both sequences (InstallUISequence and InstallExecuteSequence)