WIX:根据先前执行的自定义操作的成功情况运行自定义操作
我在安装过程中需要重新启动Windows资源管理器进程。目前我们强制用户重新启动以确保资源管理器进程真正重新启动,但我希望更灵活一些。
我有一个 restartexplorer 可执行文件,可以在安装过程中调用它。我想做的是调用 restartexplorer 可执行文件,并仅在重新启动资源管理器自定义操作返回错误代码时才使用 ScheduleReboot。
我可能会定义这样的内容:
<CustomAction Id='RestartProperty' Property='QtExecCmdLine'
Value='"[INSTALLDIR]RestartExplorer.exe"' />
<CustomAction Id='Restart' BinaryKey='WixCA' DllEntry='CAQuietExec' Execute="immediate" Return="check" />
然后 InstallExecuteSequence 会是这样的:
<InstallExecuteSequence>
...
<Custom Action="RestartProperty" Before="Restart">PREVIOUSVERSIONSINSTALLED</Custom>
<Custom Action="Restart" After="SomeAction">PREVIOUSVERSIONSINSTALLED</Custom>
<ScheduleReboot After="Restart"><![CDATA[(NOT Installed) AND (SomeErrorValue > 0)]]></ScheduleReboot>
</InstallExecuteSequence>
问题是如何从之前的自定义操作中获取错误代码?我可以使用 QtExecCmdLine 并且仍然能够检查错误代码,还是必须直接从自定义操作标记获取可执行文件?这必须适用于 Windows XP SP3 及更高版本,我更喜欢一个不必在操作系统版本之间有所不同的解决方案。
I have the need to restart the Windows Explorer process during the installation. Currently we force the user to reboot to ensure that the Explorer process is really restarted, but I would like to be a bit more flexible.
I have a restartexplorer executable which I can call during the installation. What I would like to do is to call the the restartexplorer executable and the use the ScheduleReboot only if the restart explorer custom action returns an error code.
I'll probably define something like this:
<CustomAction Id='RestartProperty' Property='QtExecCmdLine'
Value='"[INSTALLDIR]RestartExplorer.exe"' />
<CustomAction Id='Restart' BinaryKey='WixCA' DllEntry='CAQuietExec' Execute="immediate" Return="check" />
Then the InstallExecuteSequence would be something like this:
<InstallExecuteSequence>
...
<Custom Action="RestartProperty" Before="Restart">PREVIOUSVERSIONSINSTALLED</Custom>
<Custom Action="Restart" After="SomeAction">PREVIOUSVERSIONSINSTALLED</Custom>
<ScheduleReboot After="Restart"><![CDATA[(NOT Installed) AND (SomeErrorValue > 0)]]></ScheduleReboot>
</InstallExecuteSequence>
Question is how do I get the error code from the previous custom action? Can I use the QtExecCmdLine and still be able to check the error code, or do I have to the executable directly from the custom action tag? This has to work on Windows XP SP3 and newer and I would prefer a solution which didn't have to differ between OS version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建 VB 脚本自定义操作,该操作将执行以下操作:
然后如果 EXPLORER_RESTART_FAILED 为 1,则使用 ShaduleReboot。
You can create VB script custom action which will do the following:
Then use the ShaduleReboot if EXPLORER_RESTART_FAILED is 1.