Archive: Detect Windows Installer 3.1 using NSIS


Detect Windows Installer 3.1 using NSIS
Dear All,

Through my NSIS installer I want to detect whether WindowsInstaller 3.1 already exists in the system or not.

Hope, someone must have done this checking prior to the installation of WindowsInstaller 3.1

Regards,


In this meantime, I've worked around with the GetDLLVersion function and its giving me the version for it.
StrCpy $0 "$R2.$R3.$R4.$R5"
;$0 now contains the version string like "3.1.4000.2435"

So far its fine. Now how to compare the versions? The user may have Windows 3.0, then how to compare?

I tried with the following:
StrCpy $0 $0 "" 1
${VersionCompare} $0 "3.1" $1
${If} $1 == 2
MessageBox MB_YESNO "Windows Installer 3.1 or newer is required. You have $0. Upgrade WindowsInstaller?" IDYES InstallMSI
${Endif}

But the values are coming wrong for me:
$0 = .1.4000.2435 (instead of 3.1.4000.2435)
$1 = 2 (instead of 1)


$0 is corrupted because you've corrupted it with the stray StrCpy command. It copies $0 into $0, skipping the first character.


Thanks kichik for going through my issue.

I've tried by removing the StrCpy command, still the version comparasion is not working on the desired way.
After removing the StrCpy command the value of:
$0 = 3.1.4000.2435
is coming fine, but now how to compare the mine's version with the user's version. If the $0 comes blank then I know WindowsInstaller is not installed and I can carry on with my installation but problem lies if the user is having lesser version then mine's 3.1 rather 3.1.4000.2435.

Regards,


VersionCompare works fine for me, giving 1 in your case. What's the exact case where it fails for you?


Thanks for following the issue. Will get back to you soon with actual scenario. Was in a hurry, so packed the installer without version compare.

Regards,


You shouldn't have been able to compile it if you didn't include VersionCompare.


Originally posted by kichik
VersionCompare works fine for me, giving 1 in your case. What's the exact case where it fails for you?
I'm also getting value of 1. But in case when there is a lower ver. of WindowsInstaller will it be ok? I don't have 3.0, how to check then?

My Installer is bundled with 3.1version and will the following will work (note 3.0 and 3.1):

${VersionCompare} $0 "3.0" $1

To check just replace $0 with whatever mock value you want.