Search code examples
wix

WiX - Multiple RegistrySearch elements under a Property element - how it behaves


I found a similar question asked earlier (Wix RegistrySearch on multiple places), but I couldn't find a final clear answer to it. So I will reformulate and ask here.

Let's say I have multiple registry search elements defined under a Property element:

<Property Id="MyProp">
  <RegistrySearch Id="Reg1" Root="HKLM" Key="SomePath1" Name="Reg1Name" Type="raw" />
  <RegistrySearch Id="Reg2" Root="HKLM" Key="SomePath2" Name="Reg2Name" Type="raw" />
  <RegistrySearch Id="Reg3" Root="HKLM" Key="SomePath3" Name="Reg3Name" Type="raw" />
</Property>

As far as I can understand the order I have them listed inside Property is not guaranteed for execution and we don't know whichever search results in a value the last and will be assigned to MyProp (the last one overwrites the previous assignment). However, my question is what if one of the searches resulted to some value and was assigned to MyProp, but the last search didn't find anything, no result, then will MyProp value be assigned NULL or the last successful search assignment will stay intact and MyProp will have a value at the end?


Solution

  • I'm kinda suprised that's allowed. The windows installer defines the PK as Property and Signature_ so clearly it's allowed. Reading through the MSI SDK AppSearch docs I don't see it explaining the behavior in this scenario other then last one would seem to win. As the order is not presumably non-deterministic I'd say this would be dangerous to attempt.

    A safer solution would be to associate each search with it's own public property and then use one or more setproperty custom actions to assign a final property based on your own priority conditions.