You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wix 4:如何在Burn Bundle中向用户请求输入变量?

在Burn Bundle中添加用户输入SQL相关参数的简便方法

不用纠结Wix文档的复杂内容,直接用Wix内置的标准引导程序(WixStandardBootstrapperApplication)就能快速实现用户输入功能,步骤如下:

  • 1. 在Bundle中声明需要的变量
    在Bundle节点下添加Variable元素,定义SQL服务器地址、密码等需要用户输入的参数,密码变量记得设Hidden="yes"避免明文显示:

    <Bundle ...>
      <Variable Name="SQLServerUrl" Type="string" />
      <Variable Name="SqlPassword" Type="string" Hidden="yes" />
      <!-- 其他变量或配置 -->
    </Bundle>
    
  • 2. 配置自定义对话框收集用户输入
    启用标准引导程序的自定义对话框,添加输入控件绑定到上面的变量。在BootstrapperApplication节点里配置:

    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
      <WixStandardBootstrapperApplicationData
        SuppressOptionsUI="no"
        LicenseFile="path\to\your\license.rtf">
        <CustomizeDialog>
          <!-- 输入SQL服务器地址的控件 -->
          <Control Id="SQLServerUrlLabel" Type="Text" X="10" Y="100" Width="200" Height="17" Text="SQL Server 地址:" />
          <Control Id="SQLServerUrlEdit" Type="Edit" X="10" Y="120" Width="300" Height="20" Property="SQLServerUrl" />
          
          <!-- 输入SQL密码的控件 -->
          <Control Id="SqlPasswordLabel" Type="Text" X="10" Y="150" Width="200" Height="17" Text="SQL 密码:" />
          <Control Id="SqlPasswordEdit" Type="Edit" X="10" Y="170" Width="300" Height="20" Property="SqlPassword" Password="yes" />
        </CustomizeDialog>
      </WixStandardBootstrapperApplicationData>
    </BootstrapperApplicationRef>
    
  • 3. 将变量传递给目标MSI
    在需要SQL参数的MsiPackage节点下,用Property元素把Bundle的变量映射到MSI对应的属性(确保你的MSI里已经定义了这些属性):

    <MsiPackage SourceFile="path\to\your\sql-dependent.msi">
      <Property Name="SQLSERVERURL" Value="[SQLServerUrl]" />
      <Property Name="SQLPASSWORD" Value="[SqlPassword]" />
    </MsiPackage>
    

如果需要做输入验证(比如必填检查),可以在Bundle里添加Condition元素:

<Condition Message="请输入SQL服务器地址">SQLServerUrl</Condition>
<Condition Message="请输入SQL密码">SqlPassword</Condition>

内容的提问来源于stack exchange,提问作者Christian Sauer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 23:32:16