WIX run second application then first is done

风流意气都作罢 提交于 2019-12-24 18:13:22

问题


I stuck on problem with wix installer. My idea is create .msi installer, and then user install .msi , the setup.exe runs , and then user close this setup.exe(setup will install microsoft add-in) the second one(picture) will be opened sequently. Now this code below runs after checkbox is ticked two aplications both at once. Is the way to run picture only when closed first one ? Please suggest! Here is my code:

<?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>

回答1:


Kicking off installs using custom actions is a very ill-advised endeavor. It is likely to cause you only problems, and it is just not good design.

Running installers in sequence is what the WiX's bootstrapper feature Burn is for - it allows you to run MSI files and EXE files in a specified sequence.

I believe you can find a working sample of how Burn works here: https://github.com/frederiksen/Classic-WiX-Burn-Theme. Essentially it is a different type of WiX source file with its own schema designed for bootstrapper creation.



来源:https://stackoverflow.com/questions/48989030/wix-run-second-application-then-first-is-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!