ZombieCat
Posts: 6
Joined: Sat Jan 05, 2019 1:11 am

Launch condition to prevent install with older versions of Access

Here is my situation.

I have a prerequisites (Access 2013 Runtime) that is installed if no version of MS Access is installed on the computer. Using conditions I have this working just fine.

What I need next, is for the installer to fail if any version of Access 2007 or earlier is installed. This has nothing to do with the prerequisite. The installer should fail to run in this condition.

Under the Requirements -> Launch Conditions -> Software tab I can set a min version of Access to be installed. This does not work for me because there has to be a version of MS Access to be installed. If no version of Access is installed the prerequisite will be installed.

I have looked into the Custom tab on Launch Conditions but honestly I am lost on how to proceed. I do know I should be looking to see if any version of MS Access is installed that doesn't meet my requirements ([ProgramFilesFolder]Microsoft Office\Office<X>\MSACCESS.EXE) and then quit the installer. I am just lost on how to do that.

Thanks,

Jenelle
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch condition to prevent install with older versions of Access

Hello Jenelle,

From what I understand here, you would like to get the version attribute from an executable and, based on that version fail the installer (please correct me if I'm wrong).

Unfortunately, we do not have predefined support for such a task. However, we can achieve this through a custom approach.

For instance, we can have a custom action (e.g. PowerShell script, VBScript, C#, C++, etc.) that will retrieve the version form our file and then store it in a property. That property can further be used to decide whether we continue with the installation or not.

For instance, a PowerShell script which would achieve this is:

Code: Select all

# Block for declaring the script parameters.
Param()

# Your code goes here.

Add-Type -AssemblyName PresentationFramework

$exePath = "C:\Users\Catalin\Desktop\sample.exe"

# replace ',' character with the '.' character, as a version number is usually separated by a dot rather than a comma
$exeVersion = (get-item -path $exePath).VersionInfo.FileVersion.Replace(',','.')

# remove the spaces from the string (e.g. 1. 0. 0. .1 --> 1.0.0.1)
$exeVersion = $exeVersion.Replace(" ","")

AI_SetMsiProperty ACCESS_VERSION $exeVersion
In order to implement this in Advanced Installer, please proceed as it follows:
  • go to "Custom Actions" page
  • add a "Run PowerShell inline script" custom action, with sequence
  • schedule the custom action before the "Searches" action group, under the "Wizard Dialogs Stage"
  • copy paste the code given above and replace the path with your path
One thing to be noted here is the file redirection, which we must keep in mind. As you stated in your thread, the files is located in the "ProgramFilesFolder", which can either be resolved to:

WinDrive\Program Files

or to:

WinDrive\Program Files(x86)

Now, we can use the property from our script (ACCESS_VERSION) to create a custom launch condition. For instance, if we need the version to be bigger than, let's say, 7.0, the condition could look like this:

Code: Select all

ACCESS_VERSION > "7.0"
This way, the setup will only continue only if the found version is > 7.0, otherwise if it is lower, it will fail.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”