开发者

WIX: Running a custom action based on the success of previously executed custom action

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开发者_如何学JAVA="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.


You can create VB script custom action which will do the following:

  1. Run RestartExplorer.exe
  2. If it is failed set some global property (For example EXPLORER_RESTART_FAILED=1)

Then use the ShaduleReboot if EXPLORER_RESTART_FAILED is 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜