Prevent Old version of installer to overwrite new one

Got a problem you cannot solve? Try here.
Post Reply
marccastaneda
Posts: 5
Joined: Wed Feb 09, 2011 9:27 pm

Prevent Old version of installer to overwrite new one

Post by marccastaneda »

Hi,

Is there a fast way to detect if you are overwriting a newer version of your application? It seems installaware allows this.

Thanks

Marc
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Prevent Old version of installer to overwrite new one

Post by giaviv »

Marc,

If you run an older installer and a newer version is installed, your user will be prompted to to remove the installed version.
This is because IA uses revision codes, and whenever this code is different, the older version would be removed.

You can modify the section that deals with previous version uninstallation in MSIcode and read the current version from the registry, and only remove the installed version if its older.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Obliterator
Posts: 53
Joined: Fri May 01, 2009 11:54 am

Re: Prevent Old version of installer to overwrite new one

Post by Obliterator »

I added a simple lookup for this scenario to our install logic.
Just add the following lines to the 'Check/Install Application Pre-Requisites' region near the beginning of your script.

Code: Select all

Comment: Determine 64bit mode
Set Variable ISWINDOWS64BIT to FALSE
Get System Setting Windows in 64 bit Mode into ISWINDOWS64BIT

Comment: Read existing version from registry (note on 64bit machines IA seems to store this in the wow section, hopefully will get fixed at some point in the future)
Set Variable EXISTINGVERSION to 
Set Variable EXISTINGLOCATION to 
if Variable ISWINDOWS64BIT Equals TRUE
  Read Registry Key HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$PRODUCTCODE$\DisplayVersion into EXISTINGVERSION
  Read Registry Key HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$PRODUCTCODE$\InstallLocation into EXISTINGLOCATION
  else
  Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$PRODUCTCODE$\DisplayVersion into EXISTINGVERSION
  Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$PRODUCTCODE$\InstallLocation into EXISTINGLOCATION
end
Comment: Check we are not upgrading to an older version
if Variable EXISTINGVERSION Greater Than (Version) $VERSION$
  MessageBox: $TITLE$ Setup, WARNING: A newer version of $TITLE$ is already installed on this computer. The version you are trying to install is out of date (older than the installed version).$NEWLINE$$NEWLINE$Already Installed: $EXISTINGVERSION$$NEWLINE$About To Install: $VERSION$$NEWLINE$$NEWLINE$Downgrading to an older version is possible, but not recommended. Your data may now be in a newer file format which the old version cannot understand.$NEWLINE$$NEWLINE$If you are experiencing a problem with the newer version, we recommend you contact support and obtain a hotfix or newer update which addresses your problem (rather than downgrading).$NEWLINE$$NEWLINE$If you still wish to downgrade, despite these warnings you may continue to do so. The existing (newer) installation will be uninstalled before installation continues.$NEWLINE$$NEWLINE$Continue with downgrade?
  if Variable WIZARD Equals CANCEL
    Terminate Installation
  end
end
Post Reply