Page 1 of 1

Prevent downgrading of installation

Posted: Tue May 17, 2011 8:46 am
by MatthewFinch
Hello,

I was wondering if there was a way to prevent downgrading of an installation?

As IA uninstalls before overinstalling there is no way that it can use the usual WISE technique of only updating files if file date time is newer than current. Therefore, is there a way to read the 'product version' (e.g. 1.5.0.0) of the currently installed version of the software and prevent installation if 'product version' within the new installation .exe is less than current (e.g. 1.3.0.0).

I need to be able to generate a single .exe for a product that has improving versions of the application but stop a user from downgrading once they have upgraded as changes made to things like database structures etc cannot be undone.

I have read entries and know that there is no formal way for IA to run a fresh install if no current version is present but run an overinstall (without uninstall) if current version is present and only replace files with more recent date time.

Any help on this matter would be great.

Cheers,

Matt Finch

Re: Prevent downgrading of installation

Posted: Tue May 17, 2011 12:19 pm
by giaviv
Dear Matt,

You can read the DisplayVersion registry entry located in:
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{ProductCode}
and compare it to the installer version.

Re: Prevent downgrading of installation

Posted: Wed May 18, 2011 3:35 am
by MatthewFinch
Hi,

Thanks for the reply.

I now have the registry entry available for comparison. However, I was wondering if there was an easier way to get the installer version as a decimal value like 'Version' registry entry instead of string format like 'DisplayVersion' entry. This makes life much easier as I can simply use 'greater than' comparison. My version string format is x.x.x.x which follows historical structure. Therefore, to do valid comparison on string I would need to chop out the four parts of each string and compare which makes life annoying!

I don't think there is a predefined variable for version as hex/decimal but only as displayversion string format. Any ideas would be very helpful.

Kind Regards,

Matt

Re: Prevent downgrading of installation

Posted: Wed May 18, 2011 4:16 am
by giaviv
Matt,

I think you got a little confused here - $VERSION$ predefined variable refers to the version of the current running setup.
The DisplayVersion in the registry is the version of the currently installed setup - there is no predefined variable that magically gets the version of the installed setup :)

Re: Prevent downgrading of installation

Posted: Wed May 18, 2011 4:45 am
by MatthewFinch
I hope I am not that confused! :)

Registry for currently installed application has values of

DisplayVersion 2.15.0.0

also has

Version 0x020F0000 (34537472)
VersionMajor 0x00000002 (2)
VersionMinor 0x0000000F (15)

When I run my script I currently read the DisplayVersion from the registry. I then compare this to currently running setup which has pre defined variable $Version$. The $Version$ variable returns in same format as DisplayVersion (format = x1.x2.x3.x4 e.g. 2.14.0.0) . Therefore to make sure I don't downgrade I would need to compare the two string formats x1 >= x1, x2 >= x2, x3 >= x3, x4 >= x4. A bit long winded in MSIcode. Therefore I was wondering if there is a possibility to convert variable $Version$ to a DWord so that I can read the Version entry from the registry and simply do a greater than comparison.

I hope that is a little more clearer explanation.

Cheers

Matt

Re: Prevent downgrading of installation

Posted: Wed May 18, 2011 6:57 am
by MatthewFinch
Have sorted it now. Thanks for the help.

Re: Prevent downgrading of installation

Posted: Wed May 18, 2011 8:59 am
by giaviv
Dear Matt,

You are welcome to share your experience with us so other users can use your knowledge as well!

Re: Prevent downgrading of installation

Posted: Mon May 23, 2011 5:53 am
by MatthewFinch
That's a good point!

Re: Prevent downgrading of installation

Posted: Mon May 23, 2011 7:05 am
by giaviv
Thank you Matt.