All,
I have only recently been able to have the time and sit down to script this all out for my organization
We have no issues (crossed fingers) with this script after deploying to over 20K endpoints and have seen a few forum posts about how to get it all done and thought I would share my method with the community
It my first article so it may not be as readable as others.
Basically, you need to download all the prerequisite patches and standalone installer for x86 and x64
Place in similar folder structure below and use my script to set in the Software package top use as a SWD Policy or Task.
Download both the x86/x64 IE11 standalone installers and extract contents to respective folders ( IE11_x64, IE11_x86 )
http://www.microsoft.com/en-us/download/internet-e...
Use this syntax to extract and move to respective folder structure -
IE11-Windows6.1-x86-en-us.exe /x:C:\temp\IE10_x86
IE11-Windows6.1-x64-en-us.exe /x:C:\temp\IE10_x64
Download all the prerequisite patches (both bit levels) from their KB articles and place into the PreReq folder.
(if the patch name does not equal the name in the script or in my folder layout below then you have not downloaded the correct one)
So your folder structure should look similar to this after downloading and extracting, if going to import as Software in the console:
+---Microsoft
| \---Internet Explorer 11 with Prereq
| | IE11Installer-Win7.vbs
| |
| +---IE11_x64
| | HARDWAREBLOCKINGLIST.XML
| | IE-Hyphenation-en.MSU
| | IE-Spelling-en.MSU
| | IE-Win7.CAB
| | IE_SUPPORT_amd64_en-US.CAB
| | SETUPDOWNLOADLIST.TXT
| | SQMAPI.DLL
| |
| +---IE11_x86
| | HARDWAREBLOCKINGLIST.XML
| | IE-Hyphenation-en.MSU
| | IE-Spelling-en.MSU
| | IE-Win7.CAB
| | IE_SUPPORT_x86_en-US.CAB
| | SETUPDOWNLOADLIST.TXT
| | SQMAPI.DLL
| |
| \---PreReq
| Windows6.1-KB2533623-x64.msu
| Windows6.1-KB2533623-x86.msu
| Windows6.1-KB2639308-x64.msu
| Windows6.1-KB2639308-x86.msu
| Windows6.1-KB2670838-x64.msu
| Windows6.1-KB2670838-x86.msu
| Windows6.1-KB2729094-v2-x64.msu
| Windows6.1-KB2729094-v2-x86.msu
| Windows6.1-KB2731771-x64.msu
| Windows6.1-KB2731771-x86.msu
| Windows6.1-KB2786081-x64.msu
| Windows6.1-KB2786081-x86.msu
| Windows6.1-KB2834140-v2-x64.msu
| Windows6.1-KB2834140-v2-x86.msu
| Windows6.1-KB2882822-x64.msu
| Windows6.1-KB2882822-x86.msu
| Windows6.1-KB2888049-x64.msu
| Windows6.1-KB2888049-x86.msu
Folder size is approx. 139MB
You may modify my script as needed but it is pretty thorough and I have documented it some as well for your reference.
It will always create its log files under C:\Support\Logs
I have also added a registry key at the end of the install to prevent IE from autoupdating itself (you can comment out or remove the line if you see fit)
When creating the Software Resource:
Use the command line of: cscript.exe //nologo "IE11Installer-Win7.vbs"
Add these success codes: 0, 3010, 999
For the Detection Rule use (unless you have a better way):
Of course the targeted endpoint requires a reboot for it to complete which you can add to the script or task if warranted.
Please feel free to ask any qiestions or provide feedback.
Thank you,
Clay
<<VBscript Code>>
'***************************************************************************
' Name: IE11Installer-Win7.vbs
'' Author: AltirisJunkie
' Date: Nov 24, 2014
' Modified:
'' Comment:
'' Usage: -
''***************************************************************************
' Return Codes
' 0 : Success
' 099 : Unable to bind to WMI provider
' 100 : The current operating system bit level cannot be determined
' 101 : XP OS was detected
' 102 : 32 bit OS Found - Exit
' 103 : MSIEXEC could not become available within 30 seconds.
' 999 : IE11 already detected
''***************************************************************************
' CHANGES:
'---------------------------------------------------------------------------------------------
'////////////////////////////////BEGIN STANDARD SCRIPT LOGIC\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'---------------------------------------------------------------------------------------------
Option Explicit
On Error Resume Next
'********************BEGIN GLOBAL DECLARATIONS******************************
Const HKEY_LOCAL_MACHINE = &H80000002
Public RetVal
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim CurrentDir, strComputerName, strSysDomain, strSysDomainPri, strSysDomainAlt
Dim OSbit, OSName, AppName, LocalPackageDir
Dim sLogFileLocation, sLogFileName
Dim bEnableLogging, bIncludeDateStamp, bPrependDateStampInLogFileName
Dim sOverWriteORAppend, vLogMaximumLines, vLogMaximumSize
'********************END GLOBAL DECLARATIONS********************************
'***********************SET BASIC OBJECTS***********************************
Dim strComputer : strComputer = "."
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oNet : Set oNet = CreateObject("Wscript.Network")
Dim oShell : Set oShell = CreateObject("Wscript.Shell")
Dim oLocator : Set oLocator=CreateObject("WbemScripting.SWbemLocator")
Dim oEnv : Set oEnv = oShell.Environment("PROCESS")
Dim oReg : Set oReg = GetObject("winmgmts:\\"& strComputer & "\root\default:StdRegProv")
Dim oWMIService : Set oWMIService = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\"& strComputer & "\root\cimv2")
Dim RegExp : Set RegExp = New RegExp
RegExp.IgnoreCase = True
'*********************END SET BASIC OBJECTS*********************************
'****************************SET MISC***************************************
' Waiting 3 seconds to allow objects to initialize
'WScript.Sleep 2000
AppName = "IE11Installer-Win7"' Rename with script name or purpose for proper log file creation
oEnv("SEE_MASK_NOZONECHECKS") = 1
CurrentDir = oFSO.GetParentFolderName(Wscript.ScriptFullName)
LocalPackageDir = "C:\Support\Packages\"& AppName
strComputerName = oShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strSysDomain = UCase(GetComputerDomain) ' Retrieves the computers current Fully Qualified Domain Name via WMI
'strSysDomain = UCase(RegRead("HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Domain"))' Retrieves the computers current Domain Name WITHOUT WM
' Created logging folder if does not exist and prepares file for logging of script functions
' Use logging functionality anywhere in script with the following context:
' LogToFile " -----> Input whatever you want to log here"
SetupGlobalLogging
' Get the Operating System Bit Archetecture so you can used script on either 32 or 64 bit clients
' Use the If command to branch out based on bit level ex.. ( If OSBit = "32" Then ....... )
GetOSArch
' Gets the Operating System name set in the registry at install to help with logging and
' Branching of Bit level wont work and need to do it based on OS type
OSName = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
' Get drive space info. Assists in troubleshooting install issues
Dim oLogicalDisk, dTotalSpace, dFreeSpace
' Set oLogicalDisk = oWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
Set oLogicalDisk = oFSO.GetDrive("C:")
dFreeSpace = FormatNumber((CDbl(oLogicalDisk.FreeSpace)/1024/1024/1024)) & " GB"
dTotalSpace = FormatNumber((CDbl(oLogicalDisk.TotalSize)/1024/1024/1024)) & " GB"'oLogicalDisk.FreeSpace
Dim strIPs
GetLocalIP
'****************************END MISC***************************************
'---------------------------------------------------------------------------------------------
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\END STANDARD SCRIPT LOGIC/////////////////////////////////////
'---------------------------------------------------------------------------------------------
LogToFile " *** Ready to execute the "& AppName & " at "& Date & ""& Time & " ***"
LogToFile ""
LogToFile " -----> OS Version:"& Chr(9) & OSName & ""& OSbit & " bit"
LogToFile " -----> Computername:"& Chr(9) & strComputerName
LogToFile " -----> Domain:"& Chr(9) & Chr(9) & strSysDomain
LogToFile ""
LogToFile " -----> -------------------------------------------------------------------------------------------------------------------"
LogToFile " -----> Software Team Debug Info = Domain - WMI:"& strSysDomainPri & " ~ Domain - Regitry: "& strSysDomainAlt
LogToFile " -----> C:\ Drive Space Info = Total Space: "& dTotalSpace & " ~ Free Space: "& dFreeSpace
LogToFile " -----> Current Local IP addresses = "& strIPs
LogToFile " -----> -------------------------------------------------------------------------------------------------------------------"
LogToFile " -----> Script Version - Nov242014"
LogToFile ""
LogToFile ""'---------------------------------------------------------------------------------------------
'//////////////////////////////BEGIN LOCALIZED SCRIPT LOGIC\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'---------------------------------------------------------------------------------------------
Dim strProgFiles
' Exit if OS is XP
If Instr(1, OSName, "XP", 1) Then
WScript.Quit(101)
End If
If OSbit = "32" Then
strProgFiles = oShell.ExpandEnvironmentStrings( "%PROGRAMFILES%" )
Else
strProgFiles = oShell.ExpandEnvironmentStrings( "%PROGRAMFILES(x86)%" )
End If
' Check IE11 already exists
If CHeckIEVer = "11" Then
LogToFile " -----> Internet Explorer 11 has been detected. Exit."
WScript.Quit(999)
Else
If OSbit = "32" Then
'-----------------------------------------------------------------------------------Start 32 Bit Install-----------------------------------------------------------------------------------------------
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2533623 (Insecure library loading could allow remote code execution)
LogToFile " -----> Installing update KB2533623_x86 for Insecure library loading could allow remote code execution..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2533623-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2533623_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2731771 (local/UTC time conversion)
LogToFile " -----> Installing update KB2731771_x86 for local/UTC time conversion fix..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2731771-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2731771_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2639308 (Introduces the Force ASLR (Address Space Layout Randomization) feature)
LogToFile " -----> Installing update KB2639308_x86 for introducing the Force ASLR (Address Space Layout Randomization) feature..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2639308-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2639308_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2670838 (graphics and imaging issues fix - platform update)
LogToFile " -----> Installing update KB2670838_x86 for graphics and imaging issues fix (Platform update)..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2670838-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2670838_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2729094 (Segoe UI symbol font)
LogToFile " -----> Installing update KB2729094_x86 for Segoe UI symbol font..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2729094-v2-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2729094_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2786081 (Internet Explorer 10 does not save credentials for a website)
LogToFile " -----> Installing update KB2786081_x86 for Internet Explorer 10 does not save credentials for a website..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2786081-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2786081_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2834140 (Stop Error correction after installing KB2670838)
LogToFile " -----> Installing update KB2834140_x86 for Stop Error correction after installing KB2670838 fix..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2834140-v2-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2834140_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2882822 (Update adds ITraceRelogger interface support)
LogToFile " -----> Installing update KB2882822_x86 for update adds ITraceRelogger interface support..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2882822-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2882822_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 32-bit patch for KB2888049 (improves the network performance of Internet Explorer 11)
LogToFile " -----> Installing update KB2888049_x86 for improving the network performance of Internet Explorer 11..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2888049-x86.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2888049_x86")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install Internet Explorer 11 for 32-bit
LogToFile " -----> Installing Internet Explorer 11 for 32-bit..."
LogToFile " -----> Install log: C:\Support\Logs\Microsoft_IE_11_Detailed.log"'Factory installer: RetVal = oShell.Run(CurrentDir & "\IE11-Windows6.1-x32-en-us.exe /quiet /update-no /closeprograms /norestart /log:C:\Windows\Logs\",0,True)
RetVal = oShell.Run("C:\Windows\System32\dism.exe /online /add-package /packagepath:"& Chr(34) & CurrentDir & "\IE11_x86\IE-Win7.CAB"& Chr(34) & " /quiet /norestart /logpath:C:\Support\Logs\Microsoft_IE_11_Detailed.log",0,True)
If RetVal = 3010 Then
LogToFile " -----> WARNING: Installation of Internet Explorer 11 has completed successfully, however, required reboot was suppressed!"
RegWriteAdvanced "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\EnableAutoUpgrade",0,"REG_DWORD"
WScript.Quit(0)
ElseIf RetVal <> 0 Then
LogToFile " -----> ERROR: Installation of Internet Explorer 11 has failed with error: "& RetVal
Else
LogToFile " -----> Installation of Internet Explorer 11 has completed successfully."
RegWriteAdvanced "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\EnableAutoUpgrade",0,"REG_DWORD"
End If
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
Else
'-----------------------------------------------------------------------------------Start 64 Bit Install-----------------------------------------------------------------------------------------------
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2533623 (Insecure library loading could allow remote code execution)
LogToFile " -----> Installing update KB2533623_x64 for Insecure library loading could allow remote code execution..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2533623-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2533623_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2731771 (local/UTC time conversion)
LogToFile " -----> Installing update KB2731771_x64 for local/UTC time conversion fix..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2731771-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2731771_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2639308 (Introduces the Force ASLR (Address Space Layout Randomization) feature)
LogToFile " -----> Installing update KB2639308_x64 for introducing the Force ASLR (Address Space Layout Randomization) feature..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2639308-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2639308_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2670838 (graphics and imaging issues fix - platform update)
LogToFile " -----> Installing update KB2670838_x64 for graphics and imaging issues fix (Platform update)..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2670838-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2670838_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2729094 (Segoe UI symbol font)
LogToFile " -----> Installing update KB2729094_x64 for Segoe UI symbol font..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2729094-v2-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2729094_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2786081 (Internet Explorer 10 does not save credentials for a website)
LogToFile " -----> Installing update KB2786081_x64 for Internet Explorer 10 does not save credentials for a website..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2786081-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2786081_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2834140 (Stop Error correction after installing KB2670838)
LogToFile " -----> Installing update KB2834140_x64 for Stop Error correction after installing KB2670838 fix..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2834140-v2-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2834140_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2882822 (Update adds ITraceRelogger interface support)
LogToFile " -----> Installing update KB2882822_x64 for update adds ITraceRelogger interface support..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2882822-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2882822_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install 64-bit patch for KB2888049 (improves the network performance of Internet Explorer 11)
LogToFile " -----> Installing update KB2888049_x64 for improving the network performance of Internet Explorer 11..."
RetVal = oShell.Run("wusa.exe "& Chr(34) & CurrentDir & "\PreReq\Windows6.1-KB2888049-x64.msu"& Chr(34) & " /quiet /norestart /log",0,True)
Results("KB2888049_x64")
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
If MsiexecAvailable(30) Then
'install Internet Explorer 11 for 64-bit (includes 32-bit)
LogToFile " -----> Installing Internet Explorer 11 for 64-bit..."
LogToFile " -----> Install log: C:\Support\Logs\Microsoft_IE_11_Detailed.log"'Factory installer: RetVal = oShell.Run(CurrentDir & "\IE11-Windows6.1-x64-en-us.exe /quiet /update-no /closeprograms /norestart /log:C:\Windows\Logs\",0,True)
RetVal = oShell.Run("C:\Windows\System32\dism.exe /online /add-package /packagepath:"& Chr(34) & CurrentDir & "\IE11_x64\IE-Win7.CAB"& Chr(34) & " /quiet /norestart /logpath:C:\Support\Logs\Microsoft_IE_11_Detailed.log",0,True)
If RetVal = 3010 Then
LogToFile " -----> WARNING: Installation of Internet Explorer 11 has completed successfully, however, required reboot was suppressed!"
RegWriteAdvanced "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\EnableAutoUpgrade",0,"REG_DWORD"
WScript.Quit(0)
ElseIf RetVal <> 0 Then
LogToFile " -----> ERROR: Installation of Internet Explorer 11 has failed with error: "& RetVal
Else
LogToFile " -----> Installation of Internet Explorer 11 has completed successfully."
RegWriteAdvanced "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\EnableAutoUpgrade",0,"REG_DWORD"
End If
Else
LogToFile " -----> MSIEXEC could not become available within 30 seconds. Exit installer"
WScript.Quit(103)
End If
End If
End If
WScript.Quit(RetVal)
'---------------------------------------------------------------------------------------------
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\END LOCALIZED SCRIPT LOGIC////////////////////////////////////
'---------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------
'///////////////////////////BEGIN LOCALIZED FUNCTIONS-SUBROUTINES\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'---------------------------------------------------------------------------------------------
Function CHeckIEVer
Dim sFile, strQuery, objFile, colFiles, IEver
sFile = strProgFiles & "\Internet Explorer\iexplore.exe"
strQuery = "Select * from CIM_Datafile Where Name = '" + Replace(sFile, "\", "\\") + "'"
Set colFiles = oWMIService.ExecQuery(strQuery)
For Each objFile in colFiles
CHeckIEVer = Left(objFile.Version,2)
Next
End Function
Function Results(KBname)
Select Case RetVal
Case 9009
LogToFile " -----> WARNING: "& KBname & " is already installed; skipping installation."
Case 2359302
LogToFile " -----> WARNING: "& KBname & " is already installed; skipping installation."
Case -2145124329
LogToFile " -----> WARNING: "& KBname & " is not required for this system; skipping installation."
Case Else
LogToFile " -----> Install of "& KBname & " has completed with return code: "& RetVal
End Select
End Function
'---------------------------------------------------------------------------------------------
'\\\\\\\\\\\\\\\\\\\\\\\\\\END LOCALIZED FUNCTIONS-SUBROUTINES////////////////////////////////
'---------------------------------------------------------------------------------------------
'---------------------------------------------------------------------------------------------
'//////////////////////////BEGIN STANDARD FUNCTIONS-SUBROUTINES\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'---------------------------------------------------------------------------------------------
' Determine CPU architecture of the installed OS of the computer
' ------------------------------------------------------------------------------------------------------
Sub GetOSArch
' Determine CPU architecture
Dim strOSbitValue
strOSbitValue = RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier")
' 32 bit OS
If (InStr(strOSbitValue, "x86")) Then
OSbit = "32"'LogToFile " OS Bit Level = "& OSbit
'64 bit OS
ElseIf (InStr(strOSbitValue, "64")) Then
OSbit = "64"'LogToFile " OS Bit Level = "& OSbit
Else
'Log the Error
LogToFile " -----> The current operating system bit level cannot be determined - please investigate manually"
WScript.Quit(100)
End If
End Sub
' Subroutine to get the name of the installed OS of the computer
' ------------------------------------------------------------------------------------------------------
Sub GetOSName
Dim colItems, oItem, theValue
Set colItems = oWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
For Each oItem in colItems
OSName = oItem.Caption
Next
'OSName = theValue
'LogToFile " OS Name = "& OSName
End Sub
' Function to get the domain that the computer is part of
' ------------------------------------------------------------------------------------------------------
Function GetComputerDomain()
On Error Resume Next
Dim OpSysSet, i
Set OpSysSet = GetObject("winmgmts:\root\cimv2").ExecQuery("select * from Win32_ComputerSystem")
For Each i in OpSysSet
' There should only be one anyway, but we'll do this to be sure to be sure.
GetComputerDomain = i.Domain
Next
End Function
' Stores all local IP addresses into the IPAddress(i) array
' ------------------------------------------------------------------------------------------------------
Sub GetLocalIP
Dim objWMIService, IPConfigSet, IPConfig, i
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
If Not Instr(IPConfig.IPAddress(i), ":") > 0 Then
strIPs = strIPs & IPConfig.IPAddress(i) & ""
End If
Next
End If
Next
End Sub
' Check and wait for X number of seconds for Msiexec.exe to become available for use
' Pass a number in seconds when calling. ie. If WaitforMSI(30) Then....
' ------------------------------------------------------------------------------------------------------
Function MsiexecAvailable(MaxWait)
Dim Counter, oWMIServiceMSI, colProcesses, objProcess
Counter = 0
Do Until MsiexecAvailable Or Counter > MaxWait
Set oWMIServiceMSI = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\"& "."& "\root\cimv2")
Set colProcesses = oWMIServiceMSI.ExecQuery ("Select * From Win32_Process Where Name='msiexec.exe'")
' Check if any process is currently running
If (colProcesses.Count>0) Then
' One ore more msiexec.exe processes are running
For Each objProcess In colProcesses
' Check each process found and verify
If (InStr (objProcess.Commandline,"/V")=0) Then
WScript.sleep 1000
Counter = Counter + 1
Exit For
Else
If (colProcesses.Count=1) Then _
MsiexecAvailable = True
End If
Next
Else
MsiexecAvailable = True
End If
Loop
End Function
' Writes a registry item (regtype = REG_SZ, REG_BINARY, ...)
'Examples:
'RegWriteAdvanced "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoRestartShell",1,"REG_DWORD"' ---------------------------------------------------------------------------------------------------
Function RegWriteAdvanced(Name, iValue, RegType)
On Error Resume Next
RegWriteAdvanced = oShell.RegWrite(Name, iValue, RegType)
If Err Then
RegWriteAdvanced = Err.Number
Err.Clear
Else
RegWriteAdvanced = 0
End If
End Function
' Reads a registry item
' This will read the value into a variable when used
' Example:
' myvar = Regread("HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Au Options")
' If myvar = whatever then do something ....
' ------------------------------------------------------------------------------------------------------
Function RegRead(Name)
On Error Resume Next
RegRead = oShell.RegRead(Name)
If Err Then
If Err.Number = -2147024894 Then ' registry value or keydoesn't exist
' do Nothing
RegRead = ""
LogToFile " -----> Having issues reading the registry key - "& Name
Else
LogToFile " -----> RegRead"& " - "& Err.Number & ": "& Left(Err.Description, Len(Err.Description) - 0)
RegRead = ""
End If
Err.Clear
Else
' niks
End If
End Function
' Generates a folder path is does not exist
' ---------------------------------------------------------------------------------------------------
Function GeneratePath(pFolderPath)
GeneratePath = False
If Not oFSO.FolderExists(pFolderPath) Then
If GeneratePath(oFSO.GetParentFolderName(pFolderPath)) Then
GeneratePath = True
Call oFSO.CreateFolder(pFolderPath)
End If
Else
GeneratePath = True
End If
End Function
' Sets basic logging settings within script
' ---------------------------------------------------------------------------------------------------
Sub SetupGlobalLogging
'********** Create bak file if needed **********
If oFSO.FileExists("C:\Support\Logs\"& AppName & ".bak") Then
oFSO.DeleteFile("C:\Support\Logs\"& AppName & ".bak")
End If
If oFSO.FileExists("C:\Support\Logs\"& AppName & ".txt") Then
oFSO.MoveFile "C:\Support\Logs\"& AppName & ".txt", "C:\Support\Logs\"& AppName & ".bak"
End If
'********** Create Install Log Folder **********
GeneratePath("C:\Support\Logs")
GeneratePath("C:\Support\Packages")
'Specify the log file location here. Path
'must contain a trailing backslash. If you
'would like to log to the same location as
'the currently running script, set this
'value to "relative" or uncomment out the
'line below.
sLogFileLocation = "C:\Support\Logs\"'sLogFileLocation = "relative"'Specify the log file name here.
sLogFileName = AppName & ".txt"'---------LogToFile Configuration---------
'NOTE: The values specified here must be
'set before calling the LogToFile sub.
'You can disable logging globally by
'setting the bEnableLogging option to false.
bEnableLogging = True
'Setting this to true will time stamp Each
'message that is logged to the log file
'with the current date and time.
bIncludeDateStamp = True
'This will set the log file name to the
'current date and time. You can use this
'option to create incremental log files.
bPrependDateStampInLogFileName = False
'You can set whether or not you would like
'the script to append to an existing file,
'or if you would like it to overwrite
'existing copies. To overwrite set the
'sOverWriteORAppend variable to "overwrite"
sOverWriteORAppend = "overwrite"'Here you can set the maximum number of
'lines you like to record. If the maximum
'is reached the beginning of the log file
'will be pruned. Setting this to a value
'of 0 will disable this function.
vLogMaximumLines = 0
'This is just like limiting the log file
'to a number of lines but limits by the
'total size of the log file. This value
'is in bytes. Setting this to 0 will
'disable this function.
vLogMaximumSize = 0
'-------END LogToFile Configuration-------
End Sub
' Sets advanced settings for logging within script
' ---------------------------------------------------------------------------------------------------
Sub LogToFile(Message)
'Anywhere you'd like to log a message within the script you'd simply
'Add LogToFile "Your Message" to log the relevant information
If bEnableLogging = False Then Exit Sub
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim oLogFSO, oLogShell, oLogFile
Dim sNow, sLogFile
Set oLogFSO = CreateObject("Scripting.FileSystemObject")
If sLogFileLocation = "relative" Then
Set oLogShell = CreateObject("Wscript.Shell")
'sLogFileLocation = "C:\Support\Logs\"'sLogFileLocation = CreateObject("Scripting.FileSystemObject").GetAbsoluteCurrentDir(".") & "\"
sLogFileLocation = oLogFSO.GetParentFolderName(Wscript.ScriptFullName) & "\"'WScript.Echo sLogFileLocation
Set oLogShell = Nothing
End If
If bPrependDateStampInLogFileName Then
sNow = Replace(Replace(Now(),"/","-"),":",".")
sLogFileName = sNow & " - "& sLogFileName
bPrependDateStampInLogFileName = False
End If
sLogFile = sLogFileLocation & sLogFileName
If sOverWriteORAppend = "overwrite" Then
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
sOverWriteORAppend = "append"
Else
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForAppending, True)
End If
If bIncludeDateStamp Then
Message = Now & ""& Message
End If
oLogFile.WriteLine(Message)
oLogFile.Close
If vLogMaximumLines > 0 Then
Set oReadLogFile = oLogFSO.OpenTextFile(sLogFile, ForReading, True)
sFileContents = oReadLogFile.ReadAll
aFileContents = Split(sFileContents, vbCRLF)
If Ubound(aFileContents) > vLogMaximumLines Then
sFileContents = Replace(sFileContents, aFileContents(0) & _
vbCRLF, "", 1, Len(aFileContents(0) & vbCRLF))
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
oLogFile.Write(sFileContents)
oLogFile.Close
End If
oReadLogFile.Close
End If
If vLogMaximumSize > 0 Then
Set oReadLogFile = oLogFSO.OpenTextFile(sLogFile, ForReading, True)
sFileContents = oReadLogFile.ReadAll
oReadLogFile.Close
sFileContents = RightB(sFileContents, (vLogMaximumSize*2))
Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
oLogFile.Write(sFileContents)
oLogFIle.Close
End If
oLogFSO = Null
End Sub
'---------------------------------------------------------------------------------------------
'\\\\\\\\\\\\\\\\\\\\\\\\\\\END STANDARD FUNCTIONS-SUBROUTINES////////////////////////////////
'---------------------------------------------------------------------------------------------