Wix在第一次完成后运行第二个动作

时间:2018-01-30 14:04:45

标签: wix windows-installer wix3 wix3.6

然后我安装我的设置并选中复选框以启动我的应用程序,然后按完成安装程序立即运行两个程序(setup.exe并打开图片)。是运行setup.exe然后setup.exe完成安装运行图片的方法。我的意思是逐个运行动作而不是同时运行的方法?这是我的.wxs代码:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" UpgradeCode="xxxxxxxxxxxxxx" Version="$(var.ProductVersion)" Language="1033" Name="xxxxxx" Manufacturer="xxxx 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="My Application Name">
        </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="Launch My Application Name" />

<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="[#a.png]" />  
<CustomAction Id="LaunchApplication2" 
    BinaryKey="WixCA" 
    DllEntry="WixShellExec"
    Impersonate="yes"
    Return="check"/>

    <!-- 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="a.png">
        <File Id="a.png" KeyPath="yes"
              Name="a.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="a.png" />
    </Feature>
  </Product>
</Wix>

1 个答案:

答案 0 :(得分:0)

是的,对于您的情况,请使用InstallExecuteSequence。 WiX是一种声明性语言,因此您必须定义序列,否则所有内容都将按原样执行。我没有测试过这个,但是你想要执行的CustomAction的命名必须与调用WixCA的CustomAction相匹配。我不知道如何调用CustomAction中的值,但是这段代码应该让您了解如何在序列中放置CustomActions。

List<int> int_list = new List<int>();
foreach (TimeSpan delay in list)
{
  int_list.Add((int)delay.TotalMilliseconds);
}