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

Christopher Painter chrpai at iswix.com
Thu Mar 25 07:15:12 PDT 2021


PS- Make sure the Component is a 64bit component by setting the Win64 attribute to yes.   (A simple edit in stack overflow, a reply in mailing lists )

________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Christopher Painter via wix-users <wix-users at lists.wixtoolset.org>
Sent: Thursday, March 25, 2021 9:12 AM
To: wix-users at lists.wixtoolset.org <wix-users at lists.wixtoolset.org>
Cc: Christopher Painter <chrpai at iswix.com>
Subject: Re: [wix-users] How do you conditionally set a property or RegistryValue in WiX?

This is the WiX remember property pattern but a little more complicated.

Define property MyLanguageDefault with a default value for MYLANGAUGE
Use AppSearch/Reglocator (Property/RegistrySearch) to read 64bit value into 64bit temp property.
Use AppSearch/Reglocator (Property/RegistrySearch) to read 32bit value into 32bit temp property.
Use SetProperty custom action to assign 64bit temp property to MYLANGUAGE if MYLANGUAGE is null  (maybe they passed it at the command line ) and 64bit temp property is not null
Use SetProperty custom action to assign 32bit temp property to MYLANGUAGE if MYLANGUAGE is null  (maybe they passed it at the command line ) and 32bit temp property is not null
Use SetProperty custom action to assign MyLanguageDefault to MYLANAGUGE if MYLANGUAGE is null  (nothing passed at command line and nothing found in 32bit or 64bit then use default value )
Display MYLANGUAGE in a dialog if you want them to be able to be able to edit it.
Use MYLANAGUAGE in a Component/RegistryValue to write the value to the 64bit registry.

Please note that MYLANGUAGE also needs to be marked as a Secure Custom Public Property by using the Secure="yes" attribute.

________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Thomas Sondergaard via wix-users <wix-users at lists.wixtoolset.org>
Sent: Thursday, March 25, 2021 4:49 AM
To: wix-users at lists.wixtoolset.org <wix-users at lists.wixtoolset.org>
Cc: Thomas Sondergaard <thomas at sondergaard.cc>
Subject: [wix-users] How do you conditionally set a property or RegistryValue in WiX?

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

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list