Obviously, patch management can be implemented with Software Update Server (SUS), but this requires client configuration through Active Directory. Some systems, such as Windows 98, can not be configured via Group Policy, and thus can not be configured to use SUS. So we need workarounds : download patches etc (e.g. from Windows Update Catalogue, save them to a network share, and have workstations execute the downloaded patches, security updates and service packs.
One major flaw : it's not fully automatic : each patch will require confirtmation from the user to be executed. We may have to look in to silent software installation techniques to work around this.
' Koen Noens
' January 2005
'
' concept script
' execute patches which have been downloaded from Windows Update Catalogue
' just a test
' to see if a script can be used
‘ to execute software updates, patches and service packs
Option Explicit
Dim WSHShell, fso, objFile, objLogFile
Dim sFirstFolder, TAB, srcfilename, destfilename, strCommand
'init
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
TAB = chr(9)
src = "\DownloadCatalog\WU\Software\nl" ' location of patches
destfilename = "c:\MyUpdate.log"
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'main
'create log file
set objLogFile = fso.OpenTextFile(destfilename, ForWriting, True)
If src <>"" Then
ProcessFolder(FSO.getfolder(src))
Wscript.Echo "Finished"
Else
Wscript.Quit
End If
'sub
Sub ProcessFolder(objFolder)
Dim objSubFolder
'process the files in this directory, use UCASE for case-insensitive match
For Each objFile in ObjFolder.Files
If Ucase(Right(objFile.Name,4)) = ".EXE" Then
'execute it
strCommand = objFile.Path
WSHshell.Run strCommand,1,1
'WaitOnReturn=1 ; wait for execution to finish
'check also : .Exec method : run in child process
'log it 'schould check return error code for logging
objLogFile.WriteLine (ObjFile.Name & TAB & ObjFile.Path)
End If
Next
'recurse : repeat for subfolders
For Each objSubFolder in objFolder.SubFolders
ProcessFolder(objSubFolder)
Next
End Sub