Hello Sonda,
First of all, just for a better understanding of the scenario, is this what you are trying to do:
- install 64-bit prerequisite only on 64-bit OSs.
- install 32-bit prerequisite on 32-bit OSs.
- if 64-bit prerequisite
is not installed on a 64-bit OS, install the 32-bit one instead?
- if the 32-bit prerequisite
is present on the target machine,
do not install the 64-bit one?
i'm not sure how to search in both registry in same time
I am afraid this is not possible. The searches are not even done in a specific order. Windows Installer does not guarantee the searches order, so a new search should not use the result of another search.
In what regards the registry search, I think that you can make use of the
Wow6432 registry entry. The Wow6432 registry entry indicates that you're running a 64-bit version of Windows. The OS uses this key to present a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32-bit applications that run on a 64-bit version of Windows. When a 32-bit application queries a value under the
HKEY_LOCAL_MACHINE\SOFTWARE\<company>\<product> subkey, the application reads from the
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\<company>\<product> subkey.
Here is how I think you can proceed in this situation. Create a new search, add its location as "Registry", configure it for your needs (to search what you need it to search) and then, you can use a PowerShell script to create the condition. This PowerShell script will take the search property value, will place it in a variable, will parse that variable, then put its elements into an array. After doing so, you can loop through that array and search for the
"WOW6432Node" element. If that element is found, set a property value to either true or false:
- if the "WOW6432Node" element was found, set (for example) MY_PROP property to "true"
- else set the MY_PROP property to "false"
After doing so, you can use "MY_PROP" property to condition the installation of the prerequisites.
In the following lines I will give you a script sample which does pretty much all of those said above:
Code: Select all
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
$myString = "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Notepad++"
$strArr = $myString -split '\\'
$strArr
$strArr[2]
ForEach ($i in $strArr){
if($i -eq "WOW6432Node"){
[System.Windows.Forms.MessageBox]::Show('The WOW6432Node was found!')
}
else{
[System.Windows.Forms.MessageBox]::Show('The WOW6432Node was NOT found!')
}
}
As you can see above, we split the $myString variable, store it in an array. After doing so, we loop through that array and verify if any of the objects contained by the array are equal to the "WOW6432Node" string. If so, a message box is spawned to let us know if we either found our searched element or not.
Also, for more information about how you can get/set properties using PowerShell, you can have a look on the
"Run inline PowerShell script" section of our
"Custom Actions List" article.
Hope this helps.
All the best,
Catalin