Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start application after installation using WiX/Burn

I'm aware of similar questions in WiX MSI, but I'm having issues starting an application within a bootstrapper EXE file created with Burn after the installation. My full bundle is below.

If it makes any difference to the scenario, the bootstrapper is started in passive mode, so the user shouldn't need to press anything.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <Bundle Name="My Company AutoUpdater"
            Version="1.0.11"
            Manufacturer="My Company"
            UpgradeCode="--GUID--">

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">

            <bal:WixStandardBootstrapperApplication SuppressOptionsUI="yes"
                                                    LicenseUrl=""
                                                    LogoFile="logo.png" />
        </BootstrapperApplicationRef>

        <Chain>
            <MsiPackage SourceFile="..\App1\bin\Release\App1.msi" />
            <MsiPackage SourceFile="..\App2\bin\Release\App2.msi" />
        </Chain>
    </Bundle>

    <Fragment>
        <Property Id="WixShellExecTarget" 
                  Value="[#C:\Program Files (x86)\My Company\App1.exe]" />

        <Binary Id="MyCA"
                SourceFile="[#C:\Program Files (x86)\My Company\App1.exe]"/>

            <CustomAction Id="LaunchApplication"
                          BinaryKey="MyCA"
                          ExeCommand="-switch"
                          Execute="deferred"
                          Return="check"
                          HideTarget="no"
                          Impersonate="no" />

            <InstallExecuteSequence>
                <Custom Action="LaunchApplication" 
                        After="InstallFiles" />
            </InstallExecuteSequence>
    </Fragment>
</Wix>
like image 678
Fetchez la vache Avatar asked Oct 10 '12 16:10

Fetchez la vache


People also ask

How do I open a WiX project?

In Visual Studio, open your solution and add a WiX project to it: go to the Visual Studio main menu and click File -> Add -> New Project to open the Add New Project dialog. Choose the Setup Project item in the Windows Installer XML node, specify the project name and click OK.

How do I install WixUIExtension?

If you are on the command line, add -ext WixUIExtension to the call to light.exe. If you have a WiX project in Visual Studio, add a reference to "WixUIExtension" by right clicking on "References" in the Solution Explorer. See the WiXUI Dialog Sets page for WIX3.


2 Answers

You can add a variable to your Bundle called "LaunchTarget" with a path to the executable you want to run:

<Variable Name="LaunchTarget" Value="[InstallFolder]\path\to\file.exe"/>

After the install, the Setup Successful screen will display a "Launch" button that will start your app.

like image 136
levarius Avatar answered Sep 21 '22 15:09

levarius


It had a number of steps. Remember I was running this from a bootstrapper, not an MSI file, whereby levarius's answer would have sufficed.

Basically, I removed any of the launch logic that was posted in the original question, and created a new package, whose sole functionality was to kick off an application (using a custom action), and whose location had previously been saved in the registry - that is, the application running when it found that an update was available, set this item in the registry.

The package (called PostInstall below) is then run ONLY if one of the other packages has been installed previously - found by the existence of a key in the registry (set in each product's MSI). This means that no application will be started automatically after a new install has completed.

The following is from the bootstrapper bundle (WiX 3.6 in my case)

<!-- Determine what items are installed in the event of an upgrade-->
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\CompanyName"
                     Value="ProductAInstalled"
                     Variable="ProductAInstalled"
                     Result="exists"
                     Format="raw" />
<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\CompanyName"
                     Value="ProductBInstalled"
                     Variable="ProductBInstalled"
                     Result="exists"
                     Format="raw" />

<Chain>
    <!-- Package for .NET prerequisite. References a Package that is
         actually in the referenced WiX file WixNetFxExtension. -->
    <PackageGroupRef Id="NetFx40Web"/>

    <MsiPackage SourceFile="..\SetupProductA\bin\Release\SetupProductA.msi"
                InstallCondition="(chkProductA) OR (ProductAInstalled)" />

    <MsiPackage SourceFile="..\SetupProductB\bin\Release\SetupProductB.msi"
                InstallCondition="(chkProductB) OR (ProductBInstalled)" />

    <!-- Run PostInstall only if this was run as part of an upgrade. -->
    <!-- NB: This is the portion that kicks off the downloaded bootstrapper. -->
    <MsiPackage SourceFile="..\PostInstall\bin\Release\PostInstall.msi"
                InstallCondition="(ProductAInstalled) OR (ProductBInstalled)" />
</Chain>
like image 43
Fetchez la vache Avatar answered Sep 20 '22 15:09

Fetchez la vache