【问题标题】:Wix run second action after first is finishWix 在第一个动作完成后运行第二个动作
【发布时间】:2018-01-30 14:04:44
【问题描述】:

然后我安装我的设置并选中启动我的应用程序的复选框,然后按完成安装程序同时运行两个程序(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>

【问题讨论】:

    标签: wix windows-installer wix3 wix3.6


    【解决方案1】:

    是的,对于您的情况,请使用 InstallExecuteSequence。 WiX 是一种声明性语言,因此您必须定义序列,否则一切都会按原样执行。我没有对此进行测试,但是您要执行的 CustomAction 的命名必须与调用 WixCA 的 CustomAction 匹配。我不知道如何调用 CustomAction 中的值,但是这段代码的 sn-p 应该让您了解如何按顺序放置 CustomAction。

    <CustomAction Id="LaunchApplication1" Property="WixShellExecTarget"Value="[#Setup.exe]" />
    <CustomAction Id="LaunchApplication1"
        BinaryKey="WixCA"
        DllEntry="WixShellExec"
        Impersonate="yes" 
        Return="check"
        Execute="immediate"/>
    
    <CustomAction Id="LaunchApplication2" Property="WixShellExecTarget" Value="[#a.png]" />  
    <CustomAction Id="LaunchApplication2" 
        BinaryKey="WixCA" 
        DllEntry="WixShellExec"
        Impersonate="yes"
        Return="check"/>
    
    <InstallExecuteSequence>
        <Custom Action="LaunchApplication1" After="InstallFiles"/>
        <Custom Action="LaunchApplication2" After="LaunchApplication1"/>
    </InstallExecuteSequence>
    

    【讨论】:

    • 感谢@Chris N. 的回答,我照你说的做,但我收到一个错误,哪里有问题?我们的错误消息是:(编译目标)-> C:\Users\Administrator\Desktop\SetupIup\Product.wxs(48): error CNDL0181: The Custom/@After 属性的值 'LaunchApplication2' 无效,因为它会执行此操作依赖于自己。请将值更改为不同操作的名称。 [C:\Users\Administrator\Desktop\SetupIup\SetupIup.wixproj]
    • 抱歉,我打错了,因为您无法安排任务自行等待。我将 更改为 。“After”属性用于指定何时执行操作,在这种情况下“LaunchApplication2”将在“LaunchApplication1”完成后执行。
    • N,现在我有 4 个相同的错误:其中一个错误是:C:\Users\Administrator\Desktop\SetupIup - test sequi\Product.wxs(40): error LGHT0092: Location of symbol related到以前的错误。 [C:\Users\Administrator\Desktop\SetupIup - 测试 sequi\SetupIup.wixproj]
    • 也许你知道哪里出了问题?错误 LGHT0092 ant LGHT0091 ,对不起,但我尝试了任何东西:(
    猜你喜欢
    • 2014-11-16
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 2019-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多