将命令行参数从 WiX 包传递给 MSI [英] Passing command line args to MSI from WiX bundle

查看:41
本文介绍了将命令行参数从 WiX 包传递给 MSI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Wix 3.7.我有一个 MSI,我想设置一个注册表项(可能通过自定义操作,因为他必须检查该键是否已存在).

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).

我了解引导程序项目中的 Bundle 无法更改机器状态(例如设置注册表).因此,我试图通过 <MsiProperty> 传递命令行参数,但似乎没有在引导程序的日志文件中显示为命令行参数.

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. 是否可以在 Bundle 中设置注册表项?
  2. 如果没有,我如何添加命令行参数(或其他一些自定义数据)传递给MSI.
  3. MSI 如何读取我传递给它的任何内容(是否最终成为命令行 arg 或其他内容)否则).

捆绑:

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

推荐答案

您的 MSI 需要定义如下属性:

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>

此后,您可以按照此处所述在 Bootstrapper 中设置属性:WiX Bootstrapper:如何从命令行设置刻录变量?

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?

注意 SomeProperty 是一个你必须定义的 Burn 变量:

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

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

更新:

在 MSI 中,您可以根据此属性进行注册表搜索:

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" />

这篇关于将命令行参数从 WiX 包传递给 MSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆