Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix - How do I set property conditionally

Tags:

wix

I'm trying to do is:

if registrySearch exist then
  set INSTALL_DIR to C:\Program Files\MyCompany\MySoftware
else
  set INSTALL_DIR to C:\ProgramData\MyCompany\Folder

Anyone know to do this?

like image 570
WymyslonyNick Avatar asked Dec 31 '25 14:12

WymyslonyNick


1 Answers

Let say this the registry key you searched.

<Property Id="REGSEARCH">
    <RegistrySearch Id="TestReg"
                    Root="HKLM"
                    Key="Software\TestKey\TestKey2"
             Name="Test"
                    Type="raw" />
</Property>

This is how to set the property conditionally.

Keep the default value as the value you need to put when the registry does not exist.

<Property Id="INSTALL_DIR" Value="C:\ProgramData\MyCompany\Folder" />

Then set the property value as follows if the registry exists.

<SetProperty Id="INSTALL_DIR" After="AppSearch" Value="C:\Program Files\MyCompany\MySoftware" Sequence="first" >
  <![CDATA[REGSEARCH]]>
</SetProperty>
like image 181
LeoN Avatar answered Jan 08 '26 06:01

LeoN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!