【问题标题】:Change the installation based on the OS language in Wix Installer在 Wix Installer 中根据操作系统语言更改安装
【发布时间】:2014-11-26 11:07:54
【问题描述】:

我一直在使用 Wix 安装程序来创建安装程序,并且安装程序在安装过程中注册了一个端口(使用 netsh.exe)。一切正常。但后来我尝试在法语的 Windows 7 操作系统上安装应用程序……安装程序无法注册端口,因为 netsh 命令是为 en-US 编写的。 以下命令在 en-US 机器上运行良好:

netsh.exe http add urlacl url=http: //+:6700/Demo101/ user=\users 但在 fr 上失败-FR 操作系统。

对于 fr-FR,我需要运行

netsh.exe http add urlacl url=http: //+:6700/Demo101/ user=\utilisateurs

我在 Wix 项目中进行了以下更改:

<?define langLocale = [OSINSTALLEDLOCALE]?>


<?if $(var.langLocale) = "00000409"?>
<!-- Firewall exception -->
<CustomAction Id="ListenerServiceAddReservation"
              Execute="deferred"
              Impersonate="no"
              Directory="INSTALLLOCATION"
              ExeCommand="[SystemFolder]netsh.exe http add urlacl url=http://+:6700/Demo101/ user=\users"
              Return="asyncWait" />
<?else?>
<CustomAction Id="ListenerServiceAddReservation"
          Execute="deferred"
          Impersonate="no"
          Directory="INSTALLLOCATION"
          ExeCommand="[SystemFolder]netsh.exe http add urlacl url= http://+:6700/Demo101/ user=\utilisateurs"
          Return="asyncWait" />
<?endif?>

但这不起作用,因为它没有获得值“00000409”,并且总是进入法语的 else 条件并且机器在 en-US 中。

有什么帮助吗?

【问题讨论】:

    标签: wix registry


    【解决方案1】:

    使用本地化的 Wix 属性(自定义操作)来解析正确的名称,请参阅文档:http://wixtoolset.org/documentation/manual/v3/customactions/osinfo.html(网站现在已关闭,因此我无法确认正确的链接)或谷歌 WixQueryOsWellKnownSID

    在您的示例中,我假设您指的是“用户”组,因此要使其正常工作,请添加 PropertyRef

    <PropertyRef Id="WIX_ACCOUNT_USERS"/>
    

    然后在您的自定义操作中使用 [WIX_ACCOUNT_USERS] 属性,该属性将解析为内置 Windows 用户和组的正确组名。

    <CustomAction Id="ListenerServiceAddReservation"
                  Execute="deferred"
                  Impersonate="no"
                  Directory="INSTALLLOCATION"
                  ExeCommand="[SystemFolder]netsh.exe http add urlacl url=http://+:6700/Demo101/ user=[WIX_ACCOUNT_USERS]"
                  Return="asyncWait" />
    

    有了这个,你就不需要为不同的区域设置不同的自定义操作了。

    【讨论】:

      【解决方案2】:

      &lt;?if?&gt;&lt;?else?&gt; 语句是预处理器的东西,它们在编译时被解析。那是行不通的。这里的关键是内置用户和组的SID是不变的,所以需要使用S-1-5-32-545

      在 WiX v3.10/v4.0 及更高版本中,您可以使用WixHttpExtension

      <http:UrlReservation Url="http://+:6700/Demo101/">
          <http:UrlAce SecurityPrincipal="*S-1-5-32-545" Rights="register" />
      </http:UrlReservation>
      

      使用 netsh:

      netsh.exe http add urlacl url= http://+:6700/Demo101/ sddl= "O:BAG:BAD:(A;;GX;;;S-1-5-32-545)"
      

      【讨论】:

      • 谢谢肖恩。从哪里获得 WixHttpExtension?如何在项目中添加。我试过这个 xmlns:http="schemas.microsoft.com/wix/HttpExtension" 但它无法识别 UrlReservation。
      • @Vijay 直到 v3.10/v4.0 才可用,这两个版本仍在开发中。您可以在 wixtoolset.org/releases 找到每周构建
      【解决方案3】:

      感谢IlirB

      问题已解决。脚本改动很小:

      应该是 user=[WIX_ACCOUNT_USERS]

      ,而不是 user=\[WIX_ACCOUNT_USERS]

      【讨论】:

        猜你喜欢
        • 2023-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-06
        • 1970-01-01
        • 2013-11-22
        • 2014-12-11
        • 1970-01-01
        相关资源
        最近更新 更多