jav
jav

Reputation: 674

How to launch application after installation (WIX toolset v4)

This question is answered here for WIX toolset v3 but I don't seem to find a lead to do the same on WIX v4. There is this link in the official documentation making reference to WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT allowing to show a checkbox at the end which could be used to launch the application but the idea is not further developed.

BTW, if I try the solution for V3 I get an error in the publish tag.

Upvotes: 2

Views: 863

Answers (1)

jav
jav

Reputation: 674

For WIX toolset v4 there are a few changes. Namely:

  • Within the <Publish> element, the condition goes from being part of the text, to a specific attribute called Condition.
  • Within the <CustomAction> element the BinaryKey is replaced with BinaryRef

The final authoring would be as follows:

<UI Id="UI">
    <!-- Creates a basic UI for the installer -->
    <ui:WixUI Id="WixUI_Minimal" />

    <!-- Shows launch application on last screen -->
    <Publish Dialog="ExitDialog"
        Control="Finish"
        Event="DoAction"
        Value="LaunchApplication"
        Condition="WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed"/>
</UI>

<!-- Checkbox checked by default -->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>

<!-- Checkbox text message -->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.LaunchOnExit)"/>

<!-- Set our executable (its ID) as custom action target -->
<Property Id="WixShellExecTarget" Value="[#MYEXECUTABLES_ID]"/>

<!-- Run custom action -->
<CustomAction Id="LaunchApplication"
    BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
    DllEntry="WixShellExec"
    Impersonate="yes" />

Where MYEXECUTABLES_ID is defined when defining the component:

<Component Id="COMPONENT_ID" Guid="PUT-GUID-HERE">
    <File Id="MYEXECUTABLES_ID" Source="MySourceFiles\MyApplication.exe" KeyPath="yes" Checksum="yes"/>
</Component>

If the component is harvested, the file id prevails.

Upvotes: 3

Related Questions