Deploying Internet Explorer 11 … the proper way

Microsoft recommends using IEAK to create IE11 deployment package, however, based on my own (and my work colleagues) experience I know this is not the best way to create the deployment package. Due to the number of prerequisites it just loves to fail installing the browser that way.
Bellow method has been tested by me on 300+ machines (so far). There were couple of issues related to Enterprise Mode that I have identified, hence the patches added to the script. My work colleagues have tested this deployment method on if I remember correctly 2k+ machines with not a single issue. So to cut it short – it works.

Just a word, before I start.
Lets compare IE to other web browsers in terms of deployment method. How do you deploy Google Chrome? Its simple, all you need is an googlechromestandaloneenterprise.msi from here,  then you just package it with whatever deployment tool you prefer, SCCM, SMS, Altiris, PDQDeploy, AutoIT even PSExec, by simply adding /quiet /norestart (or just /qn) and ALLUSERS parameter, like this: msiexec.exe /i “googlechromestandaloneenterprise.msi” /qn ALLUSERS=2  – it just couldn’t be any easier.

Deploying Firefox in an enterprise environment is little bit more complicated, but still, its like a walk in the park comparing to IE. What you need is full redistributable installer and then you need a small .ini file with setup config where you can customize the installer. Quite straight forward to.

Internet Explorer is different :D

What do you need ?

– Prerequisites
– IE 11 installers
– Patches

Lets say we’ll be creating IE11 x86 and x64 package as we have a mix of 32 and 64-bit machines within our environment.
Create C:\IE11x86x64deploy folder – this will be your root folder.

You need to download the following prerequisites:

Download and place them all into PreReq folder within your IE11 root directory.

32-bit

–  Windows6.1-KB2533623-x86
–  Windows6.1-KB2639308-x86
–  Windows6.1-KB2670838-x86
–  Windows6.1-KB2729094-v2-x86
–  Windows6.1-KB2731771-x86
–  Windows6.1-KB2786081-x86
–  Windows6.1-KB2834140-v2-x86
–  Windows6.1-KB2882822-x86
–  Windows6.1-KB2888049-x86

64-bit

–  Windows6.1-KB2533623-x64
–  Windows6.1-KB2639308-x64
–  Windows6.1-KB2639308-x64
–  Windows6.1-KB2729094-v2-x64
–  Windows6.1-KB2731771-x64
–  Windows6.1-KB2786081-x64
–  Windows6.1-KB2834140-v2-x64
–  Windows6.1-KB2882822-x64
–  Windows6.1-KB2888049-x64

Download IE11 x86 and x64 standalone installers from here

Open command prompt and extract them into

IE11-Windows6.1-x86-en-us.exe /x:C:\IE11x86x64deploy\IE10_x86
IE11-Windows6.1-x64-en-us.exe /x:C:\IE11x86x64deploy\IE10_x64 

Download the following patches:

Download and place them all into Patches folder within your IE11 root directory.

KB292947 is an important one as it fixes an Enterprise Mode. Even though you enable Enterprise Mode via GPO, it won’t work without this patch.
Other two are cumulative security updates.

–  IE11-Windows6.1-KB2929437-x64
–  IE11-Windows6.1-KB2929437-x86 
–  IE11-Windows6.1-KB3078071-x64
–  IE11-Windows6.1-KB3078071-x86
–  IE11-Windows6.1-KB3087985-x64
–  IE11-Windows6.1-KB3087985-x86 

Now, above patches are already included in the script bellow, they are located AFTER IE11 install. If you prefer you can remove them from the script and install them separately.

Copy the script and place it into your IE11 root folder as IE11Installer-Win7.vbs
Once launched, the script will create  install log file in C:\Support\Logs .
You may wonder, why I added 3010 as a success code? There’s a suppressed reboot after IE11 install, therefore all patches will come with “3010 – restart required return code” once install is complete. Some deployment systems (ie. Altiris) see’s that as Install Failed and this will affect your compliance report.

'***************************************************************************
' Name: IE11Installer-Win7.vbs
'
' Author: AltirisJunkie
' Date: Nov 24, 2014
' Modified: Mirek Ordon
'
' Comment:  Added security patches. Added Enterprise Mode fix patch for both x86 and x64. Updated return codes.
'
' 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
'	3010 : Success
'
'***************************************************************************
' 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

		If MsiexecAvailable(30) Then
		    'install 32-bit patch for KB2929437 (Security Update for Internet Explorer 11 Fixes Enterprise Mode)
		    LogToFile "  -----> Installing update KB2929437_x86 for Security Update for Internet Explorer 11 Fixes Enterprise Mode..."
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\PreReq\IE11-Windows6.1-KB2929437-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 32-bit patch for KB3078071 (Cumulative Security Update for Internet Explorer 11 for Windows 7 for x86-based Systems)
		    LogToFile "  -----> Installing KB3078071 Cumulative Security Update for Internet Explorer 11 for Windows 7 for x86-based Systems"
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\Patches\IIE11-Windows6.1-KB3078071-x86.msu" & Chr(34) & " /quiet /norestart /log",0,True)
		    Results("KB3078071_x86")
	    Else
	    	LogToFile "  -----> MSIEXEC could not become available within 30 seconds.  Exit installer"
	    	WScript.Quit(103)
	    End If

		f MsiexecAvailable(30) Then
		    'install 32-bit patch for KB3087985 (Cumulative Security Update for Internet Explorer 11 for Windows 7 for x32-based Systems)
		    LogToFile "  -----> Installing KB3087985 Cumulative Security Update for Internet Explorer 11 for Windows 7 for x32-based Systems"
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\Patches\IE11-Windows6.1-KB3087985-x86.msu" & Chr(34) & " /quiet /norestart /log",0,True)
		    Results("KB3087985_x32")
	    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

		  If MsiexecAvailable(30) Then
		    'install 64-bit patch for KB2929437 (Security Update for Internet Explorer 11 Fixes Enterprise Mode)
		    LogToFile "  -----> Installing update KB2929437_x64 for Security Update for Internet Explorer 11 Fixes Enterprise Mode..."
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\Patches\IE11-Windows6.1-KB2929437-x64.msu" & Chr(34) & " /quiet /norestart /log",0,True)
		    Results("KB2929437_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 KB3078071 (Cumulative Security Update for Internet Explorer 11 for Windows 7 for x64-based Systems)
		    LogToFile "  -----> Installing KB3078071 Cumulative Security Update for Internet Explorer 11 for Windows 7 for x64-based Systems"
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\Patches\IIE11-Windows6.1-KB3078071-x64.msu" & Chr(34) & " /quiet /norestart /log",0,True)
		    Results("KB3078071_x64")
	    Else
	    	LogToFile "  -----> MSIEXEC could not become available within 30 seconds.  Exit installer"
	    	WScript.Quit(103)
	    End If

		f MsiexecAvailable(30) Then
		    'install 64-bit patch for KB3087985 (Cumulative Security Update for Internet Explorer 11 for Windows 7 for x64-based Systems)
		    LogToFile "  -----> Installing KB3087985 Cumulative Security Update for Internet Explorer 11 for Windows 7 for x64-based Systems"
		    RetVal = oShell.Run("wusa.exe " & Chr(34) & CurrentDir & "\Patches\IE11-Windows6.1-KB3087985-x64.msu" & Chr(34) & " /quiet /norestart /log",0,True)
		    Results("KB3087985_x64")
	    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////////////////////////////////
'---------------------------------------------------------------------------------------------

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *