Search code examples
wixregistry

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?


Solution

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