简体   繁体   中英

Detect window Installer version in bat file or inno setup

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

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM