Partilhar via


Property created in UI sequence lost its value in Execute sequence

Problem

You create a property in the UI sequence and set its value.  When you try to use this property in the Execute sequence, the property is missing or blank.

Sample

In this sample we will use Application Search to find the installation path to the Zune software during execution of the InstallUISequence.  We will use that property to launch the Zune.exe at the end of installation.

Here is the WiX source:

<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="https://schemas.microsoft.com/wix/2003/01/wi">

  <Product Id="{E2842676-5648-4A17-8993-E4BA183AAB55}"

           Name="Minimal Windows Installer Sample"

           Language="1033"

           Codepage="1252"

           Version="1.0.0"

           Manufacturer="Acme Corporation"

           UpgradeCode="{57068987-D43F-4B69-AD33-0B2CB755F6FB}">

    <Package Id="{????????-????-????-????-????????????}"

             Description="Minimal Windows Installer Sample"

             Comments="This installer database contains the logic and data required to install [ProductName]."

             InstallerVersion="200"

             Languages="1033"

             SummaryCodepage="1252"

             Platforms="Intel"

             ReadOnly="no"

             Compressed="yes"

             AdminImage="no"

             Keywords="Installer"

             ShortNames ="no"

             Manufacturer="Acme Corporation" />

    <Media Id="1" Cabinet="CAB001.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">

      <Directory Id="ProgramFilesFolder">

        <Directory Id="INSTALLDIR" Name="Minimal" LongName="MinimalInstallation">

          <Component Id="Component1"

                     Guid="{73440E8A-D60D-4600-A4EF-F9716D1D2AD8}">

            <File Id="ReadMe" DiskId="1" Name="Readme.txt" Source="Readme.txt" Vital="yes" KeyPath="yes" />

          </Component>

        </Directory>

      </Directory>

    </Directory>

    <!-- Find Zune's installation path -->

    <Property Id="ZUNEFOLDER">

      <RegistrySearch Id="ZuneReg"

                      Root="HKLM"

                      Key="SOFTWARE\Microsoft\Zune"

                      Name="Installation Directory"

                      Type="raw" />

    </Property>

    <!-- Set the property to the <path>\Zune.exe -->

    <CustomAction Id="SetZunePath"

                  Property="ZunePath"

                  Value="[ZUNEFOLDER]Zune.exe" />

    <!-- Custom action to start the executable -->

    <CustomAction Id="StartZune"

                  Property="ZunePath"

                  ExeCommand=""

                  Return="asyncNoWait" />

    <InstallExecuteSequence>

      <Custom Action="StartZune" After="InstallFinalize">Not Installed</Custom>

    </InstallExecuteSequence>

    <InstallUISequence>

      <Custom Action="SetZunePath" After="AppSearch" />

    </InstallUISequence>

    <Feature Id="Feature1"

             Title="Feature1 title"

             Description="Feature1 description"

             Level="1"

             ConfigurableDirectory="INSTALLDIR" >

      <ComponentRef Id="Component1" />

    </Feature>

  </Product>

</Wix>

Compile this code using the following commands:

d:\Wix\candle.exe Minimal.wxs

d:\Wix\light.exe -out Minimal.msi Minimal.wixobj

When we install this installation package, it installs successfully, but Zune.exe is not launched.

Let's add the custom action Type 19 to see the value of ZunePath property:

<CustomAction Id='PrintZunePath' Error='ZunePath=[ZunePath]' />

<InstallExecuteSequence>

  <Custom Action="StartZune" After="InstallFinalize">Not Installed</Custom>

  <Custom Action='PrintZunePath' After='StartZune' />

</InstallExecuteSequence>

At the end of installation we will see the message box with the message "ZunePath=".  Obviously, our ZunePath property is empty or, more likely, does not exist.  How is that possible?

Remember that Microsoft Windows Installer has two processes: client and server.  All UI sequence actions are done in the client process and all Execute sequence actions - in the server process.  Only public properties are passed from client to server process.

So, to fix this problem, simply change the name of the ZunePath property to ZUNEPATH:

<!-- Set the property to the <path>\Zune.exe -->

<CustomAction Id="SetZunePath"

              Property="ZUNEPATH"

              Value="[ZUNEFOLDER]Zune.exe" />

<!-- Custom action to start the executable -->

<CustomAction Id="StartZune"

              Property="ZUNEPATH"

              ExeCommand=""

              Return="asyncNoWait" />

<CustomAction Id='PrintZunePath' Error='ZUNEPATH=[ZUNEPATH]' />

Comments

  • Anonymous
    May 19, 2008
    The comment has been removed

  • Anonymous
    May 19, 2008
    Hmm.  That is unusual requirement.  Because there are no standard actions to run after ExecuteAction I assume you are going to use some custom action.  So, it is up to you how to pass the property back to the client process.  I don't know if Windows Installer psses properties back from server process to client process and based on your testing it does not look like it passes them back.  So, use whatever mechanism you prefer to persist property value - registry, some file in temp folder, .ini file in windows directory, etc.  Sorry, I don't know if any "standard" method exists for this particular situation. Alex

  • Anonymous
    May 20, 2008
     Thanks for your quick reply!  I do have a couple of functions already to write to and read from the registry to deal with deferred and commit CAs that need values.  However, I tried to insert an immediate Installscript CA after the ExecuteAction SA yesterday, and looking at the log, the Installer didn't even call it, so I must be doing something wrong.  Rob