How do I script the installation of the GPPEs and the pre-requisites across all my systems? PDF Print E-mail
Written by Eric Johnson   
Jun 18, 2008
GPAnswers.com very own Jakob Heidelberg has written a script that can be used as a login script to install the Group Policy Preference Extensions.  Here is the complete script:

' --------------------------------------------- '
' ----- By Jakob H. Heidelberg 29-02-2008 ----- '
' ----- - - - - - - - - - - - - - - - - - ----- '
' -----     Install GP Preference CSEs    ----- '
' -----           Developed for:          ----- '
' ----- http://heidelbergit.blogspot.com  ----- '
' ----- - - - - - - - - - - - - - - - - - ----- '
' -----           version 1.01            ----- '
' -----    Last rev. date: 01-03-2008     ----- '
' --------------------------------------------- '
' Changes:
'---------
' v1.0 Basic functionality:
' - Developed to be combined with a Startup Script (or admin rights)
' - Check if the CSEs are installed already, using local WMI call
' - Check OS Version (Windows XP, Windows Server 2003, Windows Vista), using local WMI call
' - Check OS Architecture (32 or 64 bit), just checking for a folder as WMI call was kinda strange
' - Check OS Service Pack Level, using local WMI call
' - Check for GPP CSE Pre-requisite on XP/2003 systems, using local WMI call
' - Installation of GPP CSE Pre-reqs on XP/2003 systems
' - Handles install on Windows XP SP2/SP3 32-bit (EXE file)
' - Handles install on Windows XP 64-bit, any SP level (EXE file)
' - Handles install on Windows Server 2003 SP1/SP2 32-bit (EXE file)
' - Handles install on Windows Server 2003 64-bit, any SP level (EXE file)
' - Handles install on Windows Vista RTM/SP1 32-bit (MSU package)
' - Handles install on Windows Vista RTM/SP1 64-bit (MSU package)
'
'More info:
'----------
' 1) Place ALL GPP CSE and GPP CSE Pre-Req files in the same directory (strBasePath), eg. \\DC1\UPDATES\
' 2) Description of the Windows Update Stand-alone Installer (Wusa.exe) and of .msu files in Windows Vista:
'    http://support.microsoft.com/kb/934307/en-us
' 3) NB! You might need other language version for the XmlLite GPP CSE Pre-requisites, so watch out!

Option Explicit
On Error Resume Next

'The Group Policy Preference CSE HotfixID
Dim strCSEFixID : strCSEFixID ="943729"

'Path to main update share/folder - place the 4 GPP CSE and the 3 GPP CSE Pre-Req binaries here!
Dim strBasePath : strBasePath = "\\SERVER\SHARE\" 'NB! with trailing backslash!

'GPP CSE filename for: Windows XP 32-bit / Windows Server 2003 32-bit (MD5: dfa20e51141af67ec49d574428c38fb8)
'http://www.microsoft.com/downloads/details.aspx?FamilyID=e60b5c8f-d7dc-4b27-a261-247ce3f6c4f8&DisplayLang=en
'http://www.microsoft.com/downloads/details.aspx?FamilyID=bfe775f9-5c34-44d0-8a94-44e47db35add&DisplayLang=en
Dim strXP2K332CSE : strXP2K332CSE = "Windows-en-US-KB943729-x86.exe"

'GPP CSE filename for: Windows XP 64-bit / Windows Server 2003 64-bit (MD5: 5803c6f4b4bc02ea29d934d839e0a66f)
'http://www.microsoft.com/downloads/details.aspx?FamilyID=b10a7af4-8bee-4adc-8bbe-9949df77a3cf&DisplayLang=en
'http://www.microsoft.com/downloads/details.aspx?FamilyID=29e83503-7686-49f3-b42d-8e5ed23d5d79&DisplayLang=en
Dim strXP2K364CSE : strXP2K364CSE = "Windows-en-US-KB943729-x64.exe"

'GPP CSE filename for: Windows Vista 32-bit (MD5: 22a42082473b3c8bc3b22ad095c6c31f)
'http://www.microsoft.com/downloads/details.aspx?FamilyID=ab60dc87-884c-46d5-82cd-f3c299dac7cc&DisplayLang=en
Dim strVIS32CSE : strVIS32CSE = "Windows6.0-KB943729-x86.msu"

'GPP CSE filename for: Windows Vista 64-bit (MD5: d92e107cdffa51d5943f1861f28178e7)
'http://www.microsoft.com/downloads/details.aspx?FamilyID=b10a7af4-8bee-4adc-8bbe-9949df77a3cf&DisplayLang=en
Dim strVIS64CSE : strVIS64CSE = "Windows6.0-KB943729-x64.msu"

'----------------------------------------------------------------------'
'PRE-REQUISITES - 'http://support.microsoft.com/default.aspx/kb/914783 '
'----------------------------------------------------------------------'
'GPP PreReq KB914783 filename for: Windows XP SP2 32-bit = KB915865  (MD5: 656657aeaea02d3a1069d52c4593e6e8)
'http://www.microsoft.com/downloads/details.aspx?FamilyId=D7B5DC81-AD14-4DE2-8AD5-8C4A9AAB5992&displaylang=en
Dim strXP32PRE   : strXP32PRE   = "WindowsXP-KB915865-v11-x86-ENU.exe"
Dim strPREFixID1 : strPREFixID1 = "915865"

'GPP PreReq KB914783 filename for: Windows Server 2003 SP1 32-bit = KB914783 (MD5: 830c6163fa113b782aa3cd9eb54ee549)
'http://www.microsoft.com/downloads/details.aspx?FamilyId=611D1FDE-C8D0-4D80-96DA-B5B20F7BA159&displaylang=en
Dim str2K332PRE  : str2K332PRE  = "WindowsServer2003-KB914783-v10-x86-ENU.exe"
Dim strPREFixID2 : strPREFixID2 = "914783"

'GPP PreReq KB914783 filename for: Windows XP 64-bit = KB915865 (MD5: 7fd3fc3fb21566fd97750d98e41bca0d)
'http://www.microsoft.com/downloads/details.aspx?FamilyId=C7CB26E9-68F1-4F80-B231-79D044431E8E&displaylang=en
Dim strPREFixID3  : strPREFixID3  = "915865" 'exact same install file as Windows Server 2003 SP1 64-bit (KB914783)

'GPP PreReq KB914783 filename for: Windows Server 2003 SP1 64-bit = KB914783 (MD5: 7fd3fc3fb21566fd97750d98e41bca0d)
'http://www.microsoft.com/downloads/details.aspx?FamilyId=406777E6-79DA-4414-A329-22A435A95D9D&displaylang=en
Dim strXP2K364PRE : strXP2K364PRE = "WindowsServer2003.WindowsXP-KB914783-v10-x64-ENU.exe"
Dim strPREFixID4  : strPREFixID4  = "914783"

'Commandline stuff
Dim strArgusMSU : strArgusMSU  = "/quiet /norestart"
Dim strArgusEXE : strArgusEXE  = "/quiet /passive /norestart"

Dim objFso : Set objFso = CreateObject("Scripting.FileSystemObject")

'Get SYSTEM folder, eg. C:\Windows\System32
Dim strSys : strSys = objFSO.GetSpecialFolder(1)

'Is the GPP CSE already installed? Is so, then just quit!
If IsThisHotfixInstalled(strCSEFixID) Then WScript.Quit(0)

'Is this a 64-bit windows OS?
'Get WINDOWS folder, eg. C:\Windows
Dim strWin : strWin = objFSO.GetSpecialFolder(0)
Dim strBit : strBit = "32"
If objFso.FolderExists(strWin & "\SysWOW64") Then strBit = "64"

Set objFso = Nothing

'Get OS version and Service Pack level using WMI
Dim strCSDVers, strCaption
Dim objWMI : Set objWMI = GetObject("winmgmts:\\.\root\CIMV2")
Dim colItm : Set colItm = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")
Dim objItm
For Each objItm In colItm
  strCSDVers = objItm.CSDVersion
  strCaption = objItm.Caption
Next
Set objWMI = Nothing
Set colItm = Nothing

'GET OS ARCHITECTURE
If Instr(strBit, "32") Then
   strBit = "32"
ElseIf Instr(strBit, "64") Then
   strBit = "64"
Else
   'We don't know what OS architecture it is, let's beat it...
   WScript.Quit()
End If

'GET SP LEVEL (number only)
If strCSDVers <> "" Then
   strCSDVers = Right(strCSDVers,1)
End If

Dim strCommandLineCSE, strCommandLinePRE
'GET OS VERSION (CAPTION) and Build CommandLine
If Instr(UCASE(strCaption), "VISTA") Then
  'We are dealing with a Windows Vista system
  If strBit = "32" Then
    'This is 32 bit (no SP level check)
    'No pre-req check for Windows Vista
    strCommandLineCSE = strSys & "\WUSA.EXE " & Chr(34) & strBasePath & strVIS32CSE & Chr(34) & " " & strArgusMSU
  ElseIf strBit = "64" Then
    'This is 64 bit (no SP level check)
    'No pre-req check for Windows Vista
    strCommandLineCSE = strSys & "\WUSA.EXE " & Chr(34) & strBasePath & strVIS64CSE & Chr(34) & " " & strArgusMSU
  End If
 
ElseIf Instr(UCASE(strCaption), "XP") Then
  'We are dealing with a Windows XP system
  If (strCSDVers = "2" Or strCSDVers = "3")And strBit = "32" Then
    'This is SP2 or SP3 - 32 bit
    'Install pre-req if it's not already there
    If Not IsThisHotfixInstalled(strPREFixID1) Then strCommandLinePRE = Chr(34) & strBasePath & strXP32PRE & Chr(34) & " " & strArgusEXE
    strCommandLineCSE = Chr(34) & strBasePath & strXP2K332CSE & Chr(34) & " " & strArgusEXE
  ElseIf strBit = "64" Then
    'This is 64 bit (no SP level check)
    'Install pre-req if it's not already there
    If Not IsThisHotfixInstalled(strPREFixID3) Then strCommandLinePRE = Chr(34) & strBasePath & strXP2K364PRE & Chr(34) & " " & strArgusEXE
    strCommandLineCSE = Chr(34) & strBasePath & strXP2K364CSE & Chr(34) & " " & strArgusEXE
  End If

ElseIf Instr(strCaption, "2003") Then
  'We are dealing with a Windows Server 2003 system
  If (strCSDVers = "1" Or strCSDVers = "2") And strBit = "32" Then
    'This is SP1 or SP2 - 32 bit
    'Install pre-req if it's not already there
    If Not IsThisHotfixInstalled(strPREFixID2) Then strCommandLinePRE = Chr(34) & strBasePath & str2K332PRE & Chr(34) & " " & strArgusEXE
    strCommandLineCSE = Chr(34) & strBasePath & strXP2K332CSE & Chr(34) & " " & strArgusEXE
  ElseIf strBit = "64" Then
    'This is 64 bit (no SP level check)
    'Install pre-req if it's not already there
    If Not IsThisHotfixInstalled(strPREFixID4) Then strCommandLinePRE = Chr(34) & strBasePath & strXP2K364PRE & Chr(34) & " " & strArgusEXE
    strCommandLineCSE = Chr(34) & strBasePath & strXP2K364CSE & Chr(34) & " " & strArgusEXE
  End If
Else
  'It's some other OS, let's beat it...
  Wscript.Quit()
End If

'Install GPP CSE Pre-req if strCommandLinePRE is defined
If strCommandLinePRE <> "" Then
  ExecuteThis(strCommandLinePRE)
End If

'Install GPP CSE if strCommandLineCSE is defined
If strCommandLineCSE <> "" Then
  ExecuteThis(strCommandLineCSE)
End If

Function ExecuteThis(FULLSTRING)
  Dim objShell : Set objShell = CreateObject("Wscript.Shell")
  ExecuteThis = objShell.Run(FULLSTRING,,1)
  Set objShell = Nothing
End Function

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

Last Updated ( Sunday, 29 June 2008 14:31 )
 

Be a hero! Report a problem with this web page here

Event Calendar

Find out where and when Jeremy will be speaking next.

August 2008
SMTWTFS
12
3456789
10111213141516
17181920212223
24252627282930
31
Mon, Aug 18 - Fri, Aug 22
Five Day Windows Server 2008 Upgrade Course
 James Conrad is teaching this class for a California University. If you're interested in your own Windows Server 2008 Upgrade Course let us know!
Mon, Aug 25 - Tue, Aug 26
Two-Day Intensive Group Policy Essentials Workshop (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Full week of classes in Atlanta, GA!  
This is a Two-Day Intensive Group Policy Essentials Workshop in Atlanta, GA !
Wed, Aug 27 - Thu, Aug 28
Two-Day "Group Policy 2.0" Catch-Up Workshop (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Full week of classes in Atlanta, GA!  
This is a Two-Day "Group Policy 2.0" Catch-Up Workshop in Atlanta, GA !
Fri, Aug 29 - Fri, Aug 29
One-Day Advanced Group Policy Workshop (XP/Vista Focused) (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Full week of classes in Atlanta, GA!  
This is a One-Day Advanced Group Policy Workshop (XP/Vista Focused) in Atlanta, GA !