benhinman
Posts: 37
Joined: Wed Aug 06, 2008 7:50 am

Compare previous and new product versions on upgrade.

Hi,

I would like to show/hide a label based on whether an upgrade is coming from a major version lower than the new product version.

e.g. if upgrading from 11.0.0.0 to 12.0.0.0 then show label. If upgrading from 12.0.0.1 to 12.0.0.2 then don't show label.

Is this possible?

Thanks,
Ben
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Compare previous and new product versions on upgrade.

Hi Ben,

First of all, please note that windows installer does not support versions with four fields. It is imperative that your version has three fields for your updates to work correctly. The fourth field is ignored.

The version is stored in the ProductVersion property. You can create a custom action of your own to analyze the value in ProductVersion, and set another property with the result of your analysis. Please note that only immediate custom actions can set properties.
You can then use a Control Condition to show/hide the label.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
benhinman
Posts: 37
Joined: Wed Aug 06, 2008 7:50 am

Re: Compare previous and new product versions on upgrade.

Hi Gabriel,

Thanks for the reply. We always increment the third version part when issuing an upgrade. Sorry that my example code did not reflect this.

Still not sure on how to get the previous product version...

If I reference the ProductVersion value I assume this returns the version about to be installed and not the one already on the system?!?

Thanks,
Ben
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Compare previous and new product versions on upgrade.

Hi Ben,

If you are not storing your version manually inside the registry, you could try using the Windows API to open the installed product by Product Code and retrieve its version.
Here might be a good starting point:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
You can get the product code(s) of previous versions being upgraded from the OLDPRODUCTS property.

Let me know if this is helpful.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
benhinman
Posts: 37
Joined: Wed Aug 06, 2008 7:50 am

Re: Compare previous and new product versions on upgrade.

I tried the following search:

SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[OLDPRODUCTS]

on VersionMajor.

but to no avail.

I imagine OLDPRODUCTS is not set before a search is conducted - any way to make this happen?!?!

Thanks,
Ben
benhinman
Posts: 37
Joined: Wed Aug 06, 2008 7:50 am

Re: Compare previous and new product versions on upgrade.

Instead of performing a search, I added the following attached custom action after "FindRelatedProducts":

function GetOldProductMajorVersion() {
try {
Session.Property("OLD_PRODUCT_MAJOR_VERSION") = new ActiveXObject("WScript.Shell").RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + Session.Property("OLDPRODUCTS") + "\\VersionMajor").toString();
} catch (e) { }
}

A bit nasty but whatever!

Do you know if that will work for 32 and 64 bit machines? My limited testing shows that it does.

Thanks,
Ben
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Compare previous and new product versions on upgrade.

Hi Ben,

Yes, the approach is correct and should work on 64bit too.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”