[英]Change the installation based on the OS language in Wix Installer
我一直在使用Wix安装程序来创建安装程序,安装程序在安装期间注册了一个端口(使用netsh.exe)。 一切都很好。 但后来我尝试在法语的Windows 7操作系统上安装该应用程序...安装程序无法注册该端口,因为netsh命令是为en-US编写的。 以下命令在en-US机器上正常工作:
netsh.exe http添加urlacl url = http:// +:6700 / Demo101 / user = \\ users但在fr-FR OS上失败。
对于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”并且总是进入法国和机器在en-US的其他条件。
有什么帮助吗?
使用本地化的Wix属性(自定义操作)来解析正确的名称,请参阅doc: 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" />
有了这个,您将不需要为不同的区域设置具有不同的自定义操作。
<?if?>
和<?else?>
语句是预处理程序的东西,它们在编译时解析。 那不行。 这里的关键是内置用户和组的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)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.