Option Explicit Dim arrCur, arrReq Dim i, intChk, intRC, intReq Dim objFSO, wshShell Dim strMsiExec, strVersion, strWindir intRC = 0 ' Check the command line argument(s) If WScript.Arguments.Named.Count > 0 Then Syntax If WScript.Arguments.Unnamed.Count > 1 Then Syntax If WScript.Arguments.Unnamed.Count = 1 Then arrReq = Split( WScript.Arguments.Unnamed(0), "." ) For i = 0 To UBound( arrReq ) If Not IsNumeric( arrReq(i) ) Then Syntax If CInt( arrReq(i) ) <> CDbl( arrReq(i) ) Then Syntax Next End If ' Create the required objects Set objFSO = CreateObject( "Scripting.FileSystemObject" ) Set wshShell = CreateObject( "WScript.Shell" ) ' Get the path to the Windows Installer executable (MSIEXEC.EXE) strWindir = wshShell.ExpandEnvironmentStrings( "%WinDir%" ) strMsiExec = objFSO.BuildPath( strWindir, "system32\msiexec.exe" ) If objFSO.FileExists( strMsiExec ) Then ' Get MSIEXEC.EXE's file version strVersion = objFSO.GetFileVersion( strMsiExec ) WScript.Echo strVersion ' Compare it to a specified minimum, if applicable If WScript.Arguments.Unnamed.Count = 1 Then arrCur = Split( strVersion, "." ) intChk = UBound( arrCur ) If intChk > UBound( arrReq ) Then intReq = UBound( arrReq ) For i = 0 To intChk If CInt( arrCur(i) ) < CInt( arrReq(i) ) Then intRC = 1 If CInt( arrCur(i) ) <> CInt( arrReq(i) ) Then Exit For Next End If Else intRC = 1 Syntax End If WScript.Quit intRC Sub Syntax Dim strMsg strMsg = vbCrLf _ & "WinInVer.vbs, Version 1.01" _ & vbCrLf _ & "Check the installed Windows Installer version, and optionally compare it" _ & vbCrLf _ & "to a specified minimum required version number" _ & vbCrLf & vbCrLf _ & "Usage: CSCRIPT.EXE //NoLogo wininver.vbs [ min_req ]" _ & vbCrLf & vbCrLf _ & "Where: ""min_req"" is the minimum required version, e.g. ""3.1.4000.1823""" _ & vbCrLf & vbCrLf _ & "Return codes:" _ & vbCrLf _ & " 0: installed version is equal to or newer than the specified minimum," _ & vbCrLf _ & " or no minimum version was specified" _ & vbCrLf _ & " 1: installed version is older than the specified minimum" _ & vbCrLf _ & " 2: invalid command line argument(s)" _ & vbCrLf _ & " 3: Windows Installer executable wasn't found" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" _ & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit intRC + 2 End Sub