sonda
Posts: 101
Joined: Mon Apr 30, 2018 12:01 pm

Prerequisites install combination

The application is build for any cpu, and i want to install some prerequisites, and i have included both prerequisites x64 and x86, how can achieve:
if i find x64 that is installed, not to try to install x86 prerequisite. i want to use registry search but both are looking in different registry part (for x64 its searching in x64 registry for x86 it looking in x86 registry (depending on machine) ). By default prerequisites is serching in x86, and if its clicked use 64bit locations... will search in x64, i'm not sure how to search in both registry in same time, or any other suggestion how to accomplish that wen x64 is installed not to try to install x86.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Prerequisites install combination

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
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sonda
Posts: 101
Joined: Mon Apr 30, 2018 12:01 pm

Re: Prerequisites install combination

Hi Thanks for the detail answer, the scenario is like this:

- Install 64-bit prerequisite only on 64-bit OSs.
- Install 32-bit prerequisite on 32-bit OSs.

i

if 64-bit prerequisite is not installed on a 64-bit OS, install the 64-bit one , but if you find 32-bit do not install nothing.
if its 32 os install only 32 version

let say that i have identified machine and i know that machine is 64-bit and i have mu property Is64BitMachine= true

I have this situation as on pictures:
2019_01_04_13_23_07_Window.jpg
2019_01_04_13_23_07_Window.jpg (145.98 KiB) Viewed 3688 times
this is for 32-bit version and this is set by the advanced installer, and also if i add Is64BitMachine condition this will install 32-bit because condition is set to install if at leas one condition is false

And this is condition for 64bit
2019_01_04_13_24_33_Your_Application_New_Project_English_US_Advanced_Installer_15.3_.png
2019_01_04_13_24_33_Your_Application_New_Project_English_US_Advanced_Installer_15.3_.png (49.21 KiB) Viewed 3688 times
i'm not sure how to adjust conditions not to try to install 32 bit version if machine is 64-bit, and there is installed 64 bit prerequisite
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Prerequisites install combination

Hello Sonda,

After further investigating your scenario, I think I have came up with a solution. In the following lines, you can find a step-by-step explanation on how you can achieve what you want:

- Please go to "Prerequisites" page:
- click on the x64 version of your prerequisite --> go to "Install Conditions" tab --> make sure the "32-bit Windows versions" is unchecked from under the "Supported Windows Versions" section.
- click on the x32 version of your prerequisite --> go to "Install Conditions" tab --> make sure the "64-bit Windows versions" is unchecked from under the "Supported Windows Versions" section.

- Now go to "Search" page (under "Custom Behavior" tab) --> right click --> "New extended search" --> "Registry value contains version" and configure it as it follows:

--> Registry value:

Code: Select all

HKLM\SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum\Version
--> Tick the "Search the 64-bit portion of the registry"
--> Minimum:

Code: Select all

14.10.25008
--> Maximum: leave empty

The above search will search the 64-bit portion of the registry for your prerequisite.

- Now go to "Search" page (under "Custom Behavior" tab) --> right click --> "New extended search" --> "Registry value contains version" and configure it as it follows:

--> Registry value:

Code: Select all

HKLM\SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum\Version
--> Make sure to have the "Search the 64-bit portion of the registry" unticked
--> Minimum:

Code: Select all

14.10.25008
--> Maximum: leave empty

The above search will search the 32-bit portion of the registry for your prerequisite.

Now, since both of your prerequisites are "Feature-Based", each of the prerequisites has a feature assigned to it. This feature can be conditioned and we will do so by using the earlier created searches. To do so, please go to "Organization" page, click on the feature that has the same name as your x64 prerequisite ("Visual C++ Redistributable for Visual Studio 2017 x64"). Under "Installation Behavior", select the "Not installed" radio button and, in "Installed if:" field, insert the following condition:

Code: Select all

NOT X64_SEARCH AND NOT X86_SEARCH
Please be aware that "X64_SEARCH" and "X86_SEARCH" is how I named the searches for the sake of example. You can name them as you wish.

With the above changes, I have tested the following scenarios:

1- When both prerequisites are already installed on the machine ==> None of the prerequisites installation will be deployed.

2- When X64 prerequisite is already installed on the machine ==> None of the prerequisites installation will be deployed.

3- When X64 prerequisite is already installed on the machine ==> None of the prerequisites installation will be deployed.

4- When none of the two prerequisites is already installed on the machine ==> The x64 prerequisite installation will be deployed.

The above tests were done on a 64-bit OS. On a 32-bit OS, if the 32-bit prerequisite is already installed, the installation of the 32-bit will be skipped due to the default search that is performed (the one from the "Prerequisites" page).

Attached you can find a sample project which I have created for your reference.
Sonda Sample Project.aip
(19.87 KiB) Downloaded 197 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sonda
Posts: 101
Joined: Mon Apr 30, 2018 12:01 pm

Re: Prerequisites install combination

Hi Catalin, thanks for detail respionse i think this will help, i will try to implement

Thanks again
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Prerequisites install combination

You are always welcome, Sonda.

Glad I could help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”