RudiBoy
RudiBoy

Reputation: 80

Launch application after installation does not work Wixv4

I am trying to launch my installed app after the installation is completed. I followed what is suggested here: https://docs.firegiant.com/wix3/howtos/ui_and_localization/run_program_after_install/ Only to find that the complete example does not work. It misses the Condition tag and it references a BinaryKey in the custom action that is not valid. On stack I found this How to launch application after installation (WIX toolset v4) but doing it that way does not launch the (WinForm) app either.

I am using WixToolset.Sdk/5.0.2 and the nuget packages version 5.02. My installer works with the WixUI_InstallDir gui and installs the app and the icons as expected. If I fire up the installed app manually it works just fine.

Being new to all of this I am lost on what to do to actually get it to launch after the install is finished.

Upvotes: 0

Views: 34

Answers (1)

RudiBoy
RudiBoy

Reputation: 80

After reading this post Wix - How to run exe files after installation from installed directory?. I noticed what I was doing wrong. Unaware of the significance of the # character, I simply use the SourceFileId. I later found that my code worked fine if I entered the installpath\filename as a string.

This is the working code:

    <UI Id="UI">
        <ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
        <!-- Shows launch application on last screen -->
        <Publish Dialog="ExitDialog"
            Control="Finish"
            Event="DoAction"
            Value="LaunchApplication"
            Condition="WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed"/>
        <!-- Set our executable (its ID) as custom action target -->
        <Property Id="WixShellExecTarget" Value="[#SourceFileId]"/>
    </UI>
    <!--Set some properties for the GUI-->
    <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="!(loc.DialogOptionalText)" />
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.DialogOptionalCheckBoxText)" />
    <!-- Checkbox checked by default -->
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
    
    <!-- Run custom action -->
    <CustomAction Id="LaunchApplication"
        BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
        DllEntry="WixShellExec"
        Impersonate="yes" />

The app fires up fine even if the install path is changed in the dialog.

Upvotes: 0

Related Questions