Start application after installation using WiX/Burn

ぐ巨炮叔叔 提交于 2019-12-03 09:55:09

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.

Fetchez la vache

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>

Use the advice given in the WiX manual, How To: Run the Installed Application After Setup. There is a built-in WiX extension that will handle this for you. You should be able to reference the WiX Util extension, add the following code to your project (replacing the value of the property of course), then schedule the action to run:

<Property Id="WixShellExecTarget" 
          Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication" 
              BinaryKey="WixCA" 
              DllEntry="WixShellExec" 
              Impersonate="yes" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!