【问题标题】:WIX run second application then first is doneWIX 运行第二个应用程序,然后首先完成
【发布时间】:2025-12-05 04:40:02
【问题描述】:

我遇到了 wix 安装程序的问题。我的想法是创建 .msi 安装程序,然后用户安装 .msi ,setup.exe 运行,然后用户关闭此 setup.exe(setup 将安装 microsoft add-in)第二个(图片)将依次打开。现在,下面的代码在同时勾选两个应用程序后运行。只有在关闭第一个时才能运行图片吗?请建议!这是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" UpgradeCode="b288bcab-ad20-47d5-8d2c-1111111111" Version="$(var.ProductVersion)" Language="1033" Name="Program" Manufacturer="Program LTD">
    <Package InstallerVersion="300" Compressed="yes"/>
    <Media Id="1" Cabinet="myapplication.cab" EmbedCab="yes" />

    <Property Id="ALLUSERS" Value="2" /> 
    <Property Id="MSIINSTALLPERUSER" Value="1" />

    <!-- Step 1: Define the directory structure -->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="InstallFiles" Name="Launch Program">
        </Directory>
      </Directory>
    </Directory>

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

  <!-- 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="Program" />

<CustomAction Id="PrepareLaunchApplication1" Property="WixShellExecTarget" Value="[#Setup.exe]" />
<CustomAction Id="LaunchApplication1"
    BinaryKey="WixCA"
    DllEntry="WixShellExec"
    Impersonate="yes" 
    Return="check"
    Execute="immediate"/>

<CustomAction Id="PrepareLaunchApplication2" Property="WixShellExecTarget" Value="[#picture.png]" />  
<CustomAction Id="LaunchApplication2" 
    BinaryKey="WixCA" 
    DllEntry="WixShellExec"
    Impersonate="no"
   />

    <!-- Step 2: Add files to your installer package -->
    <DirectoryRef Id="InstallFiles">
      <Component Id="Setup.exe">
        <File Id="Setup.exe" KeyPath="yes"
              Name="Setup.exe" Source="$(var.AddinFiles)"></File>
      </Component>
 <Component Id="picture.png">
        <File Id="picture.png" KeyPath="yes"
              Name="picture.png" Source="$(var.AddinFiles)"></File>
      </Component>  
    </DirectoryRef>


    <!-- Step 3: Tell WiX to install the files -->
    <Feature Id="MainApplication" Title="Main Application" Level="1">

      <ComponentRef Id="Setup.exe" />
      <ComponentRef Id="picture.png" />
    </Feature>
  </Product>
</Wix>

【问题讨论】:

    标签: xml wix windows-installer burn


    【解决方案1】:

    使用自定义操作开始安装是非常不明智的做法。它可能只会给你带来问题,而且它不是好的设计。

    按顺序运行安装程序是 WiX 的引导程序功能Burn 的用途 - 它允许您按指定顺序运行 MSI 文件和 EXE 文件。

    我相信您可以在这里找到 Burn 工作原理的工作示例:https://github.com/frederiksen/Classic-WiX-Burn-Theme。本质上,它是一种不同类型的 WiX 源文件,具有自己的架构,专为创建引导程序而设计。

    【讨论】:

    • 嗯,感谢 Stein 的回答,非常有趣的想法。也许你知道是否可以在mai完成安装并运行exe文件后运行exe,然后在运行后关闭exe,例如wellcome window?如果可能的话,最好的做法是什么?我的意思是最好的方法?谢谢!
    • @Andrej 某些功能在应用程序中比在安装程序中实现得更好。您所描述的内容听起来像是典型的“启动画面”对话框或首次运行功能。您的设置可以使用一个参数来启动应用程序,告诉它为什么要启动它 - 使用编码到应用程序中的适当处理程序。
    • 是的,我可能没有正确查看您的代码。 setup.exe 中有什么?是第三方软件吗?你想达到什么总体目标。那张照片是什么?