Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

windows installer - Passing command line args to MSI from WiX bundle

I’m on Wix 3.7. I have an MSI that I would like to set a registry key (perhaps via a Custom Action, as he will have to check if the key already exists).

I understand that a Bundle in a bootstrapper project can't change the machine state (such as setting the registry). Therefore, I'm attempting to pass a command line argument via <MsiProperty>, but doesn't appear to show up as a command line argument in my log file for the bootstrapper.

  1. Is it possible to set a registry key up in a Bundle?
  2. If not, how can I add a command line argument (or some other piece of custom data) to be passed to the MSI.
  3. How can the MSI read whatever it is I pass to it (whether It ends up being a command line arg or something else).

Bundle:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Bundle 
          Name="MyInstallerBootstrapperLocalDb" 
          Version="1.0.0.0" 
          Manufacturer="some company" 
          UpgradeCode="PUT-GUID-HERE">
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
    <Chain>
      <MsiPackage Id="MyInstallerInstaller" 
                  SourceFile="$(var.MyInstallerInstaller.TargetPath)" 
                  Compressed="no">
        <!-- TODO - if this is being set correctly, the MSI needs to 
                    interpret it and set up the key-->
        <MsiProperty Name="SetLocalDb" Value="yes"/>
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your MSI needs to define a property like so:

<Property Id="SOMEPROPERTY" Value="Default"/>

You can then set this property from the bundle:

<MsiPackage SourceFile="<package>.msi" Id="SomeId">
    <MsiProperty Name="SOMEPROPERTY" Value="[SomeProperty]" />
</MsiPackage>

After this you can set the property in the Bootstrapper as described here: WiX Bootstrapper: How do I set burn variables from the command line?

Notice that SomeProperty is a Burn variable which you have to define:

<Variable Name="SomeProperty" Type="string" Value="DefaultValue" />

Update:

In the MSI you are then able to do a registry search based on this property:

<RegistrySearch Id="GetSomeValue" Root="HKLM" Key="SOFTWARE<Manufacturer>[SOMEPROPERTY]" Name="<ValueName>" Type="raw" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...