1
votes

i am currently working on Installer in inno setup and run bat file which check the OS version and install the window installer 4.5 if OS is window xp,now i have a problem i want to detect that is window installer 4.5 is already install or not on machine ?

there is command msiexec which popup the window to show the version but i need it as a string to make a decision is there is any way to know the currently installed window installer version in bat file?

 REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto warn_and_exit

:ver_XP
start WindowsXP-KB942288-v3-x86.exe
end

it is bat file now i want to check before start window installer whether the version is 4.5 or not if < 4.5 install otherwise nothing

looking for good and fast response

regards wasif

2
I'm quite confused how this is related to InnoSetup. You want to detect the MS Installer version in InnoSetup or in batch file executed from the InnoSetup installer ? You can easily check OS and MS Installer versions from InnoSetup, that's why I don't get the part with the batch file. - TLama
Is there is anyway to find the version of window installer on inno setup? - Wasif
as i define above i am using bat file to detect OS version and if it is xp i install window installer now i want to add check is window installer in install or not ? - Wasif
It's upon you, the first option, using InnoSetup I can help you with, the second one, from batch file I can't. But if you decide one or the other, please remove the additional tags from your question ;-) - TLama
if you have solution in inno setup please provide me then i will change the setup.iss thanks - Wasif

2 Answers

3
votes

I would try something like this. You may also follow the commented version of this post:

[Files]
Source: "WindowsXP-KB942288-v3-x86.exe"; DestDir: "{tmp}"

[Run]
Filename: "{tmp}\WindowsXP-KB942288-v3-x86.exe"; Check: CheckInstallMSI; OnlyBelowVersion: 0,6.0

[code]
const
  // The minimum MSI version is 4.50.0.0
  MinMSIVersionMS = (4 shl 16) or 50;
  MinMSIVersionLS = (0 shl 16) or 0;

function CheckInstallMSI: Boolean;
var
  MSIVersionMS: Cardinal;
  MSIVersionLS: Cardinal;
begin
  Result := True;

  if GetVersionNumbers(ExpandConstant('{sys}\msi.dll'), MSIVersionMS, MSIVersionLS) then
    if MSIVersionMS >= MinMSIVersionMS then
      Result := False;
end;

Sources:

0
votes

Another solution:

function InitializeSetup(): Boolean;
var
 MS: cardinal;
 LS: cardinal;
 V1 : dword;
 V2 : dword;
 V3 : dword;
 V4 : dword;

 begin
  Result := true;
  if GetVersionNumbers(ExpandConstant('{sys}\msi.dll'), MS, LS) then
   begin
    V1 := MS shr 16;
    V2 := MS and $FFFF;
    V3 := LS shr 16;
    V4 := LS and $FFFF;
    if IntToStr(V1)+'.'+IntToStr(V2) < '4.5' then begin
        MsgBox('Your message...', mbConfirmation, MB_OK)             
        Result := False;    
    end;      
  end;    
 end;

Code reference: https://www.daniweb.com/programming/software-development/threads/297848/pascal-inno-question-re-cardinal