2012-04-24 70 views
1

我目前正在安装inno安装程序和运行bat文件检查操作系统版本和安装窗口安装程序4.5如果操作系统是窗口xp,现在我有一个问题,我想检测到窗口安装程序4.5已经安装或不在机器上?检测窗口安装程序版本的bat文件或inno安装

有命令msiexec弹出窗口来显示版本,但我需要它作为字符串来作出决定是有什么办法来知道当前安装的bat文件中的窗口安装程序版本?

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 

是bat文件,现在我要开始窗口安装前检查的版本是否为4.5或不是,如果< 4.5安装否则没什么

找好,响应速度快

问候 wasif

+1

我很困惑该如何与InnoSetup。您想要检测InnoSetup中的MS Installer版本还是从InnoSetup安装程序执行的批处理文件中?您可以轻松地从InnoSetup检查操作系统和MS安装程序版本,这就是为什么我没有获得批处理文件的部分。 – TLama 2012-04-24 15:11:10

+0

有没有办法在inno setup上找到window installer的版本? – Wasif 2012-04-24 15:54:02

+0

正如我定义上述我使用bat文件来检测操作系统版本,如果它是XP我现在安装窗口安装程序我想添加检查是安装窗口安装程序或不是? – Wasif 2012-04-24 15:55:43

回答

3

我会尝试这样的事情。您也可以按照这个帖子的commented version

[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; 

来源:

+0

谢谢你的回复,我会尝试它和我相信它会解决问题 – Wasif 2012-04-25 08:56:29

+0

嗨,我检查代码,但是当我把这个代码放在installer.iss文件中,然后安装程序无法检测到.net框架是否安装 – Wasif 2012-04-25 13:22:21

+0

它不工作:-( – Wasif 2012-04-25 14:07:43

0

另一种解决方案:

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; 

码参考:https://www.daniweb.com/programming/software-development/threads/297848/pascal-inno-question-re-cardinal