如何 运行 使用 wix 安装程序安装多个 exe?

How to run multiple installed exe's using wix installer?

我正在尝试 运行 安装后的多个 exe。此代码创建单个 msi,部署两个 exe,但 运行 第一个。 我还没有在整个互联网上找到一个例子。这是我的代码(不要介意 "put guid here"):

<?xml version="1.0" encoding="UTF-8"?>
<<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*"
             UpgradeCode="PUT-GUID-HERE"
             Version="1.0.0.0"
             Language="1033"
             Name="My Application Name"
             Manufacturer="My Manufacturer Name">    
    <Package InstallerVersion="300" Compressed="yes"/>
    <Media Id="1" Cabinet="myapplication.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="APPLICATIONROOTDIRECTORY" Name="My Application Name"/>
        </Directory>
    </Directory>

    <DirectoryRef Id="APPLICATIONROOTDIRECTORY">
        <Component Id="Installs" Guid="PUT-GUID-HERE">
            <File Id="myapplication.exe" Source="MySourceFiles\MyApplication.exe" KeyPath="yes" Checksum="yes"/>
        <File Id="myapplication2.exe" Source="MySourceFiles\MyApplication.exe2" KeyPath="yes" Checksum="yes"/>  
        </Component>
    </DirectoryRef>

    <Feature Id="MainApplication" Title="Main Application" Level="1">
        <ComponentRef Id="Installs" />
    </Feature>

    <UI>
        <UIRef Id="WixUI_Minimal" />
        <Publish Dialog="ExitDialog" 
            Control="Finish" 
            Event="DoAction" 
            Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name" />


    <Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
    <CustomAction Id="LaunchApplication" 
        BinaryKey="WixCA" 
        DllEntry="WixShellExec"
        Impersonate="yes" />
    </Product>
</Wix>

但它只会在完成安装后安装第一个 exe。想法? 最好的问候。

一个组件不能有多个键路径。根据 Windows 安装程序组件规则,每个 EXE 文件都应该是它自己的组件的关键路径。

我看不出任何东西会如何启动。 [#myapplication.exe] 是一个格式化表达式,在 ConstFinalize 之后才有效。您需要适当安排 SetProperty 自定义操作才能工作。您还需要不止一个来为要启动的每个 EXE 一遍又一遍地调用 LaunchApplication。或者创建一个唯一目的是启动其他 EXE 的自定义 EXE。

你可以只做 2 次:首先设置 属性 "WixShellExecTarget" 然后调用 "WixShellExec"。 IE。尝试用自定义操作替换以设置 属性:

<UI>
  <UIRef Id="WixUI_Minimal" />

  <!-- set property and launch the first exe -->
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="PrepareLaunchApplication1">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication1">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>

  <!-- set property and launch the second exe -->
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="PrepareLaunchApplication2">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication2">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name" />

<CustomAction Id="PrepareLaunchApplication1" Property="WixShellExecTarget" Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication1"
    BinaryKey="WixCA"
    DllEntry="WixShellExec"
    Impersonate="yes" />

<CustomAction Id="PrepareLaunchApplication2" Property="WixShellExecTarget" Value="[#myapplication2.exe]" />
<CustomAction Id="LaunchApplication2"
    BinaryKey="WixCA"
    DllEntry="WixShellExec"
    Impersonate="yes" />

如果您希望程序按顺序 运行 并等待第二个程序退出并检查其退出代码,您可以使用 "ExeCommand" 而不是 "WixShellExec"。如果您不关心退出代码,则需要相应地配置 ExeCommand(查看文档)。

<UI>
  <UIRef Id="WixUI_Minimal" />

  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication1">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication2">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>

<CustomAction Id="LaunchApplication1" FileKey="myapplication1.exe" ExeCommand="" Impersonate="yes" />
<CustomAction Id="LaunchApplication2" FileKey="myapplication2.exe" ExeCommand="" Impersonate="yes" />