[wix-users] How do you conditionally set a property or RegistryValue in WiX?

Thomas Sondergaard thomas at sondergaard.cc
Thu Mar 25 02:49:39 PDT 2021


Hi,

I have also asked the following question on stackoverflow (link
<https://stackoverflow.com/questions/66794410/how-do-you-conditionally-set-a-property-or-registryvalue-in-wix>),
in case you want to answer it there and gain points. However, after having
reviewed the answers to WiX questions on stackoverflow and on this mailing
list, I decided the odds of getting a good answer were better here. So here
is my question:

I have a Wix Toolset project with a component such as the one below, where
MYLANGUAGE is a public property that can be set when installing the product:

      <Component Id='language_reg' Guid='*' Permanent='yes'>
        <Condition>MYLANGUAGE</Condition>
        <RegistryValue Type='string' Root='HKLM'
Key='Software\MyCompany\MyProduct' Name='language'
        Value='[MYLANGUAGE]' KeyPath='yes' />
      </Component>

Now I am upgrading this software package from 32-bit 64-bit. The key above
from the existing 32-bit versions of my software is stored under
HKLM\Software\WOW6432Node\MyCompany\MyProduct because of WOW64.

After an upgrade to a new 64-bit version of the package the upgrade I would
like to have the value set in the HKLM\Software\MyCompany\MyProduct key
too. The value shall be set like this:

   - If the public property MYLANGUAGE is set when installing then the
   value of that property shall be stored in HKLM\Software\MyCompany\MyProduct
   language
   - If the public property MYLANGUAGE is not set *and*
   HKLM\Software\MyCompany\MyProduct key doesn't exist and
   HKLM\Software\WOW6432Node\MyCompany\MyProduct language value is set then I
   want the value copied from HKLM\Software\WOW6432Node\MyCompany\MyProduct
   language to HKLM\Software\MyCompany\MyProduct language

How can I do this with WIX Toolset?

Best regards,

Thomas


More information about the wix-users mailing list