简体   繁体   中英

Change the installation based on the OS language in Wix Installer

I have been using Wix installer to create the installer and the installer register a port during the installation (using netsh.exe). Everything is working fine. But then I tried to install the application on a Windows 7 OS which is French...the installer could not register the port because the netsh command was written for en-US. The following command works fine on en-US machine:

netsh.exe http add urlacl url=http: //+:6700/Demo101/ user=\\users but fails on fr-FR OS.

For fr-FR I needed to run

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

I made the following changes in Wix project:

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

But this is not working becuase it does not get the value "00000409" and always goes to else condition which is for French and machine is in en-US.

Any help please?

Use localized Wix Properties (Custom actions) to resolve correct name, see doc: http://wixtoolset.org/documentation/manual/v3/customactions/osinfo.html (site is down right now so i can't confirm the correct link) or google WixQueryOsWellKnownSID

In you example i assume you are referring to "users" group so to get it working add a PropertyRef

<PropertyRef Id="WIX_ACCOUNT_USERS"/>

Then in your Custom Action use [WIX_ACCOUNT_USERS] property which will resolve to correct group name for built-in Windows users and groups.

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

With this you won't need to have different Custom Action for different locale.

The <?if?> and <?else?> statements are preprocessor stuff, they are resolved at compile time. That won't work. The key here is that the SIDs for built-in users and groups are constant, so you need to use S-1-5-32-545 .

In WiX v3.10/v4.0 and later, you can use the WixHttpExtension :

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

Using netsh:

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

Thanks to IlirB

the issue is resolved. very little change in the script:

instead of user=\\[WIX_ACCOUNT_USERS] it should be user=[WIX_ACCOUNT_USERS]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM