Script to install CSE

Hi Guys,
I wrote a script that I used to install Group Policy Preferences Client Side Extensions.
The script checks to see what OS version it runs on, and then checks weather or not the CSE and XMLLite are already installed or not – and if not installs them from a network share.

I do however one problem with the script – It does not perform the check for XMLLite on 2003 server’s as it should and it always tries to install the update. But the good thing is that once the update starts to install it finds that it does need to be installed on the system and it stops without any error message for the users.

The other thing to notice is that this script only checks if it runs on XP or Win2K3 server (since that’s what I needed when I wrote it). But I added a short function that can check if the computer is x86 or x64 in the end of the script.

Dont forget to change “YOUR NETWORK SHARE” – well, to your network share 🙂

Option Explicit
‘*********************************************************
‘ Const Config
‘*********************************************************
Dim strPath_XPx86XML
Dim strPath_XPx86
Dim strPathXML_2003x86
Dim strPathCSE_2003x86
Dim strPathCSERU_2003x86

Dim strCSEFixID
Dim strXMLxpFixID
Dim strXML2003FixID
Dim strCSERUFixID

Dim strComputer
Dim objShell
Dim colOperatingSystems
Dim strOSVer
Dim objWMIService
Dim colItems
Dim intCount
Dim objItem
Dim objOperatingSystem

Dim oShell
Dim oEnv

‘The Group Policy Preference XML_XP HotfixID
strXMLxpFixID =”915865″
‘The Group Policy Preference XML_2003 HotfixID
strXML2003FixID =”914783″
‘The Group Policy Preference CSE HotfixID
strCSEFixID =”943729″
‘ The Group Policy Prefrence CSE Rollup HotfixID
strCSERUFixID = “974266”

‘ Path for XML Install on XP
strPath_XPx86XML = “YOUR NETWORK SHARE\XML_Lite_For_XP_x86.exe”
‘ Path for GPP Install
strPath_XPx86 = “YOUR NETWORK SHARE\CSE_ForXP_x86.exe”
‘ Path for XML install on 2003
strPathXML_2003x86 = “YOUR NETWORK SHARE\XML_Lite_For_2003_x86.exe”
‘ Path for CSE install on 2003
strPathCSE_2003x86 = “YOUR NETWORK SHARE\CSE_For2003_x86.exe”
‘ Path for CSE Rollup package for 2003
strPathCSERU_2003x86 = “YOUR NETWORK SHARE\GPP_Rollup.exe”

‘*********************************************************

‘*********************************************************
‘ This is the main function
‘ It checks the OS and runs the install according to the
‘ appropriate OS.
‘*********************************************************

‘ setting the Computer on which running
strComputer = “.” ‘ use “.” for local computer
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

‘ Getting the OS
Set colOperatingSystems = objWMIService.ExecQuery(“Select * from Win32_OperatingSystem”)
For Each objOperatingSystem in colOperatingSystems
strOSVer = objOperatingSystem.Version
Next

‘Run correct patch install
Set objShell = CreateObject(“Wscript.Shell”)
Select Case Left(strOSVer, 3)
Case “5.2”
‘Windows 2003
‘*********************************************************
‘ Checking if XML installed, and installing if not
‘*********************************************************

If Not IsThisHotfixInstalled(strXML2003FixID) then
Set objShell = CreateObject(“Wscript.Shell”)
objShell.run strPathXML_2003x86 & ” /quiet /log:C:\KB914783.log”,0,True
Set objShell = Nothing
End If

‘*********************************************************
‘ Checking if CSE installed, and installing if not
‘*********************************************************

If Not IsThisHotfixInstalled(strCSEFixID) then
Set objShell = CreateObject(“Wscript.Shell”)
objShell.run strPathCSE_2003x86 & ” /quiet /log:C:\KB943729.log”,0,True
Set objShell = Nothing
End If

‘*********************************************************
‘ Checking if CSE Rollup installed, and installing if not
‘*********************************************************

If Not IsThisHotfixInstalled(strCSERUFixID) then
Set objShell = CreateObject(“Wscript.Shell”)
objShell.run strPathCSERU_2003x86 & ” /quiet /log:C:\KB974266.log”,0,True
Set objShell = Nothing
End If

Case “5.1”
‘Windows XP
‘*********************************************************
‘ Checking if XML installed, and installing if not
‘*********************************************************

If Not IsThisHotfixInstalled(strXMLxpFixID) then
‘ Disabling the Security Dialog box
set oShell= CreateObject(“Wscript.Shell”)
set oEnv = oShell.Environment(“PROCESS”)
oEnv(“SEE_MASK_NOZONECHECKS”) = 1

‘ Running install
Set objShell = CreateObject(“Wscript.Shell”)
objShell.run strPath_XPx86XML & ” /quiet /passive /log:C:\KB914783.log”,0,True
Set objShell = Nothing

‘ Removing the system environments
oEnv.Remove(“SEE_MASK_NOZONECHECKS”)
msgbox “installed XML”
End If

‘*********************************************************
‘ Checking if CSE installed, and installing if not
‘*********************************************************

If Not IsThisHotfixInstalled(strCSEFixID) then
‘ Disabling the Security Dialog box
set oShell= CreateObject(“Wscript.Shell”)
set oEnv = oShell.Environment(“PROCESS”)
oEnv(“SEE_MASK_NOZONECHECKS”) = 1

‘ Installing CSE
Set objShell = CreateObject(“Wscript.Shell”)
objShell.run strPath_XPx86 & ” /quiet /log:C:\KB943729.log”,0,True
Set objShell = Nothing

‘ Removing the system environments
oEnv.Remove(“SEE_MASK_NOZONECHECKS”)
End If
End Select

‘*********************************************************
‘ The Function that checks if the XML_Lite update is exists.
‘ The Functions get a KBNUMBER as a parameter,
‘ and checks if that KBNUMBER is installed or not.
‘ The return code is 0 if not intalled and 1 if installed
‘*********************************************************
Function IsThisHotfixInstalled(KBNUMBER)
Dim objWMI : Set objWMI = GetObject(“winmgmts:\\.\root\CIMV2”)
Dim colItm : Set colItm = objWMI.ExecQuery(“SELECT * FROM Win32_OperatingSystemQFE”)
IsThisHotfixInstalled = False
Dim objItm
For Each objItm In colItm
If Instr(objItm.Dependent,KBNUMBER) Then
IsThisHotfixInstalled = True
Exit For
End If
Next
Set colItm = Nothing
Set objWMI = Nothing
End Function

‘*************************************************************************
‘ added additional inforamtion in case diffrent situation

‘*****************KB Numbers nedded*************
‘ CSE FOR XP:
‘ X86 – KB943729
‘ X64 – KB943729

‘ CSE FOR 2003:
‘ X86 – KB943729
‘ X64 – KB943729

‘ XML FOR XP:
‘ X86 – KB915865
‘ X64 – KB915865

‘ XML FOR 2003:
‘ X86 – KB914783
‘ X64 – KB914783

‘************to check the system type (86/64 bit) add this*******
‘ Set colComputerSystems = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)
‘ For Each objComputerSystem in colComputerSystems
‘ strSysType = objComputerSystem.SystemType

‘ If Left(strSysType,3) = “X86” Then
‘**************************************************************************************************

What do you think about this post?