views:

1224

answers:

1

This should be easy, but after several hours I’m coming up blank. ;(

I do a Registry Search (actually 2), because I need to check for either of 2 previous installs and then install my new files to the location of the prior install that was found.

  • Only one of these prior installs will actually exist.

I then need to install my new files to the 'InstallLocation' of which 'PROD#' was found.

<!—Look for the UnInstall key of the 1st possible product -->
<!— GUID = {E928E024-DEFE-41A7-8469-D338212C4943} -->
<Property Id='PROD1'>
  <RegistrySearch Id='PROD_REG1' Type='raw'
              Root='HKLM' Key='$(var.REGKEY_PROD1)' Name='InstallLocation' />
</Property>

<!—Look for the UnInstall key of the 2nd possible product -->
<!— GUID = {A40A9018-DB9D-4588-A591-F012600C6300} -->
<Property Id='PROD2'>
  <RegistrySearch Id='PROD_REG2' Type='raw'
              Root='HKLM' Key='$(var.REGKEY_PROD2)' Name='InstallLocation' />
    </Property>

<!-- ? How to set INSTALL_HERE Property to whichever ‘InstallLocation’ was found ? -->

<!-- Define the directory structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALL_HERE">
    <Directory Id="MAIN_DIRECTORY" Name="MyProduct"/>  
    <Directory Id="HELP_DIRECTORY" Name="Help"/>      
  </Directory>
</Directory>
+3  A: 

The following will set properties A and B to the result of two different registry searches. If the search for B was successfull, it overrides the value of A with the value of B.

  <Property Id="A">
     <!-- registry search 1 here -->
  </Property>

  <Property Id="B">
     <!-- registry search 2 here -->
  </Property>

  <SetProperty Id="A" After="AppSearch" Value="[B]">
     B
  </SetProperty>

Note how the SetProperty element uses the value of B twice: once as Value="[B]" to override the value of A, and once as the condition text of the custom action. The After="AppSearch" ensures that the custom action is executed right after the registry searches.

See also this answer of Rob Mensching

Wim Coenen
Many thanks!1> Agent_9191: Yes, that's basically what I need to do.My app is on add-on to a product, and the only way I can know where the 'main' product is installed (and if it IS installed) is by looking at the 'main' product Uninstall info in the Registry.My issue comes from the fact that whenever the 'main' product is updated, the previous Uninstall info is gone and replaced by the info for the latest update. And if they update it again, I'll need a 3rd Registry search!2> wcoenen: Like I said : This should be easy", but I just was NOT getting it.*** Thanks for your help! ***
Zerren