'ManageEngine Desktop Central 'Pre requisite patches for windows 7 SP1 32 bit to install IE 11 '=============================================================== On Error Resume Next set returncode = 0 patch=Array("%WINDIR%\\system32\\wusa.exe Windows6.1-KB2888049-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2882822-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2786081-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2729094-v2-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2670838-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2834140-v2-x86.msu /quiet /norestart",_ "%WINDIR%\\system32\\wusa.exe Windows6.1-KB2726535-x86.msu /quiet /norestart") ' enter supersede patch here regkey = Array("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2888049~31bf3856ad364e35~x86~~6.1.1.1\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2882822~31bf3856ad364e35~x86~~6.1.1.2\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2786081~31bf3856ad364e35~x86~~6.1.1.0\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2729094~31bf3856ad364e35~x86~~6.1.2.0\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-PlatformUpdate-Win7-SRV08R2-Package-TopLevel~31bf3856ad364e35~x86~~7.1.7601.16492\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2834140~31bf3856ad364e35~x86~~6.1.1.1\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2834140~31bf3856ad364e35~x86~~6.1.2.0\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2533623~31bf3856ad364e35~x86~~6.1.1.2\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2731771~31bf3856ad364e35~x86~~6.1.1.1\CurrentState",_ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB2726535~31bf3856ad364e35~x86~~6.1.1.1\CurrentState") regvalue = Array("49",_ "49",_ "49",_ "49",_ "49",_ "49",_ "49",_ "49",_ "49",_ "49") Set WshShell = CreateObject("WScript.Shell") for i = LBound(regkey) To UBound(regkey) -5 wscript.echo regkey(i) & Chr(10) & regvalue(i) ret = IsRegistryValuegreater(regkey(i),regvalue(i)) 'wscript.echo ret strExpandedString = WshShell.ExpandEnvironmentStrings(patch(i)) if ret = 0 then returncode=WshShell.Run(strExpandedString, 0, TRUE) if returncode <> 0 then returnValue = returncode End if wscript.echo strExpandedString & Chr(10) & " Returns error code " & returncode & Chr(10) else wscript.echo strExpandedString & Chr(10) & "Already Installed" & Chr(10) end if next 'for detecting KB2834140 based on two registry keys set retVal = 0 for j = ( UBound(regkey) - 4 ) To ( UBound(regkey) -3 ) wscript.echo regkey(j) & Chr(10) & regvalue(j) retVal = IsRegistryValuegreater(regkey(j),regvalue(j)) if retVal <> 0 then exit for end if 'wscript.echo retVal next strExpandedString = WshShell.ExpandEnvironmentStrings(patch(UBound(patch)-1)) ' install KB2834140 patch if retVal = 0 then returncode=WshShell.Run(strExpandedString, 0, TRUE) if returncode <> 0 then returnValue = returncode End if wscript.echo strExpandedString & Chr(10) & " Returns error code " & returncode & Chr(10) else wscript.echo strExpandedString & Chr(10) & "Already Installed" & Chr(10) end if ' for checking last three supersede patch set ret = 0 for j = (UBound(regkey) -2 ) To UBound(regkey) wscript.echo regkey(j) & Chr(10) & regvalue(j) ret = IsRegistryValuegreater(regkey(j),regvalue(j)) if ret <> 0 then exit for end if 'wscript.echo ret next strExpandedString = WshShell.ExpandEnvironmentStrings(patch(UBound(patch))) if ret = 0 then returncode=WshShell.Run(strExpandedString, 0, TRUE) if returncode <> 0 then returnValue = returncode End if wscript.echo strExpandedString & Chr(10) & " Returns error code " & returncode & Chr(10) else wscript.echo strExpandedString & Chr(10) & "Already Installed" & Chr(10) end if Wscript.Quit returnValue '==================================================== 'Script to check given value found in Registry value '==================================================== Function IsRegistryValuegreater(theEntry , gvalue) On error resume next set shell = CreateObject("WScript.Shell") entry = shell.RegRead(theEntry) If Err.Number = 0 then 'wscript.echo CInt(entry) if CInt(entry) > CInt(gvalue) then Err.Clear IsRegistryValuegreater = 1 'wscript.echo "greater" else Err.Clear IsRegistryValuegreater = 0 'wscript.echo "value not greater" end if else Err.Clear IsRegistryValuegreater = 0 'wscript.echo "not found" end if End Function