Monday, July 23, 2012

WiX Custom Action - Copy MSI after Install

In WiX there is a functionality to execute application after successfully closing the setup in async mode.
Add following in the .wxs file and execute candle.exe with usual commands.

<Property Id="WixShellExecTarget" Value="[CommonAppDataFolder]Product_Data\test.exe" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<UI>
   <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">NOT Installed</Publish>
</UI>

In command line compilation for Light.exe following "-ext" needed to add.
These extensions will allow use of WixUIExtension.dll and WixUtilExtension.dll.

light.exe d:\abc\test.wixobj -ext WixUIExtension -ext WixUtilExtension -out d:\abc\test.msi

This is the basic logic behind executing any exe after completing setup. This application executes in async mode and in my case I have used it to copy the present MSI from its present location to program data for safekeeping. This copy MSI is a simple implementation of copying file from one location to another hence not including that code here.

Reference
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Why-doesn-t-this-work-Opening-PDF-at-Finish-button-click-td3087051.html

No comments:

Post a Comment