如何在简单的WIX msi中传递命令行参数?

时间:2015-01-15 21:29:06

标签: wix

msiexec / i myproduct.msi LANG = 1。

我没有bootstraper项目,我有简单的Product.wxs文件的wix项目。如果lang = 1,我不想执行3级功能。基于lang参数我试图设置一个变量来设置要写入HKLM或HKCU的注册值

 <Feature Id="ProductFeature"  Level="1">
      <Condition  Level="2">LANG=1</Condition>
      <Condition  Level="3">LANG=0</Condition>
      <Feature Id="MyFeatureBHJ" Title="My Feature BGJ" Level="2">
          <?define DllRegLocationGj = "HKCU" ?>
          <ComponentGroupRef Id="ProductComponents" />          
      </Feature>
      <Feature Id="MyFeatureBHJttgj" Title="My Feature BjjGJ" Level="3">
        <?define DllRegLocationGj = "HKLM" ?>
        <ComponentGroupRef Id="ProductComponents" />            
      </Feature>
 </Feature>

2 个答案:

答案 0 :(得分:0)

由于您知道运行时需要哪个注册表项,为什么不从父项功能中移出嵌套功能(&#34; MyFeatureBHJ&#34;和#34; MyFeatureBHJttgj&#34;) #34; ProductFeature&#34 ;?然后直接通过命令行传递功能名称?

msiexec /i install.msi ADDLOCAL= ProductFeature ,MyFeatureBHJ

or 

msiexec /i install.msi ADDLOCAL= ProductFeature , MyFeatureBHJttgj

更新:理想情况下,您的Feature元素将如下所示:

    <Feature Id="ProductFeature"  Level="1">             
              <!--All components list goes here-->
     </Feature>
    <Feature Id="MyFeatureBHJ" Title="My Feature BGJ" Level="1">
              <!--Component specific to feature BHJ-->          
    </Feature>
    <Feature Id="MyFeatureBHJttgj" Title="My Feature BjjGJ" Level="1">
              <!--Component specific to feature BHJttgj-->          
    </Feature>

答案 1 :(得分:0)

你是对的,你的答案应该有效,谢谢。但在我的情况下,当我通过命令行安装功能&#34; U&#34;时,它设置的变量是HKLM而不是HKCU

msiexec / i OfficeAddInSetup.msi ADDLOCAL =&#34; U&#34;

  <Feature Id="U" Title="Excel Add-in" Level="1">
   <?define DllRegLocationGj = "HKCU" ?>
    <ComponentRef Id="ExcelRegistry_FriendlyName_HKCU" />       
  </Feature>  

  <Feature Id="L" Title="Excel Add-in" Level="1">
   <?define DllRegLocationGj = "HKLM" ?>
    <ComponentRef Id="ExcelRegistry_FriendlyName_HKLM" />       
  </Feature>

      <Component Id="ExcelRegistry_FriendlyName_HKCU">
        <RegistryValue Id="ExcelRegistry_FriendlyName_HKCU" Root="$(var.DllRegLocationGj)"
                       Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn"
                       Name="FriendlyName"
                       Value=ExcelAddIn"
                       Type="string" KeyPath="yes" />
      </Component>



      <Component Id="ExcelRegistry_FriendlyName_HKLM">
        <RegistryValue Id="ExcelRegistry_FriendlyName_HKLM" Root="$(var.DllRegLocationGj)"
                       Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn"
                       Name="FriendlyName"
                       Value="ExcelAddIn"
                       Type="string" KeyPath="yes" />
      </Component>