使用WiX/Burn安装后启动应用程序

Fet*_*che 19 installation wix bootstrapper burn wix3.6

我知道WiX MSI中存在类似的问题,但是我在安装后使用Burn创建的引导程序EXE文件中启动应用程序时遇到问题.我的完整包在下面.

如果它对场景有任何影响,则引导程序以被动模式启动,因此用户不需要按任何内容.

<?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>
Run Code Online (Sandbox Code Playgroud)

lev*_*ius 17

您可以向Bundle中添加一个名为"LaunchTarget"的变量,其中包含要运行的可执行文件的路径:

<Variable Name="LaunchTarget" Value="[InstallFolder]\path\to\file.exe"/>
Run Code Online (Sandbox Code Playgroud)

安装完成后,"安装成功"屏幕将显示"启动"按钮,该按钮将启动您的应用程序.

  • 嗨levarius谢谢你的回复.我可以创建启动按钮,当用户点击MSI时工作正常没问题.不幸的是,当MSI以被动模式启动时(即,用户在此过程中没有交互的情况下,此方法不起作用 - 例如,Process.Start("Bootstrapper.exe","/ passive");).在这种情况下,MSI只是在不"使用"启动目标的情况下终止. (2认同)

Fet*_*che 5

它有很多步骤.记住我是从一个引导程序运行它,而不是MSI文件,levarius的答案就足够了.

基本上,我删除了原始问题中发布的任何启动逻辑,并创建了一个新包,其唯一功能是启动应用程序(使用自定义操作),并且其位置先前已保存在注册表中 - 也就是说,当应用程序发现更新可用时运行,请在注册表中设置此项.

然后,如果先前已经安装了其他软件包之一,则可以运行该软件包(下面称为PostInstall) - 通过注册表中存在密钥(在每个产品的MSI中设置)找到该软件包.这意味着在安装完成后不会自动启动任何应用程序.

以下是来自bootstrapper捆绑包(在我的情况下是WiX 3.6)

<!-- 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>
Run Code Online (Sandbox Code Playgroud)