如何将Burn安装程序UI中复选框状态传递至MSI安装包
Great question! To pass the checked/unchecked state of your InstallXfemilyCheckbox to your MSI, you'll need to link the checkbox to a Burn variable, then map that variable to an MSI property using <MsiProperty>. Here's a step-by-step breakdown:
1. Add a Variable to Your Checkbox Control
First, update your Checkbox definition in the Install page to include a Variable attribute (this tells Burn to store the checkbox's state in a named variable). You can also set a DefaultValue to ensure the variable has a predictable value even when the checkbox is unchecked:
<Checkbox Name="InstallXfemilyCheckbox" X="150" Y="-70" Width="246" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="yes" Variable="INSTALL_XFAMILY" DefaultValue="0"> Veraltete Programme auch installieren </Checkbox>
Variable="INSTALL_XFAMILY": This Burn-side variable holds the checkbox state (value is1when checked,0when unchecked, thanks to theDefaultValue).DefaultValue="0": Ensures the variable defaults to "0" if the user doesn't interact with the checkbox, avoiding empty/unset values that could break MSI logic.
2. Map the Burn Variable to an MSI Property
Next, in your Bundle's <MsiPackage> element, use <MsiProperty> to pass the Burn variable's value to a corresponding property in your MSI. The Name is the property name you'll define in your MSI, and the Value uses Burn's variable syntax ([VariableName]) to reference the checkbox state:
<MsiPackage SourceFile="YourApplication.msi" Id="YourMsiPackageId"> <!-- Map Burn variable to MSI property --> <MsiProperty Name="INSTALL_XFAMILY" Value="[INSTALL_XFAMILY]" /> </MsiPackage>
Here, NAME-IN-MSI becomes INSTALL_XFAMILY (the property name in your MSI), and Value-Seen-In-MSI is [INSTALL_XFAMILY] (the Burn variable linked to the checkbox).
3. Prepare the MSI to Receive the Property
Finally, make sure your MSI is set up to accept this property:
- Define a Public Property: In your MSI's Property table, add a property named
INSTALL_XFAMILYwith a default value of0. - Secure the Property (if needed): If your installer requires UAC elevation, add
INSTALL_XFAMILYto theSecureCustomPropertieslist in the Property table. This prevents the property from being filtered out during elevation.
Once set up, when the user checks the checkbox, the MSI will receive INSTALL_XFAMILY=1; if unchecked, it will receive INSTALL_XFAMILY=0. You can then use this property in your MSI's logic (e.g., conditional component installation, custom actions) to control whether the legacy programs are installed.
内容的提问来源于stack exchange,提问作者Thomas Woelfer

