2012-04-24 75 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