An important feature that Inno Setup fails to provide is to uninstall old versions before installing a new version. When I prepared Code Beautifier Collection 6.0 Milestone 3, I started to think about this feature. Luckily because I have experienced Pascal script already, I soon found a way.
Every installer place some information in your registry in order to display an item in your Control Panel's Add/Remove Programs. In your Inno Setup script under [Setup] section, you should specify AppVersion and AppID. For example,
As a result, some registry items are added.
So in [Code] section you can use Pascal script to do version string comparison to see if there is an older version.
Do something in InitializeSetup gives you a chance to exit the installation if necessary.
First, I try to see if CBC was installed. Using AppID makes thing easy.
Second, I read AppVersion from registry named 'DisplayVersion'.
Then, I compare the read result with current version, 6.0.0.1004.
At last, if there is a newer or the same version installed, exit. If an older version is there, uninstall it and continue to install this new version.
Because Inno Setup does not provide version string comparison function, I wrote customized code first in Delphi 2007 and then copied the code to Inno Setup script. This is an important thing, that you can debug the code in Delphi while you cannot debug it in Inno Setup,
These function should be placed at the beginning of [Code] section.
Currently, I do not know how to access AppID of [Setup] section in [Code] section, so all version strings are hard coded. Once I find a way to do so, those hard coded strings can be replaced.
In fact, I prefer Pascal script to MSIcode in InstallAware and I will continue using Inno Setup for CBC. Pascal programming has become part of my life.
Actually I tried to search on Google before actions, and the only useful entry returned from query is a post on
AgileTrack Blog. however, that approach is a complicated approach. I believe my code is simpler and make full use of existing information in your registry. BTW, you can download the full iss file from
http://code.google.com/p/lextudio/source/browse/trunk/trunk/setup/CBC2Exe.iss
[Update: You can find all my Inno Setup posts at http://www.lextm.com/search/label/Inno%20Setup]