'==========================================================================
' NAME: Windows Update Check
' COMMENT: Simple Check for Pending Reboots to finish applying updates
' AUTHOR: Padraig Lennon
' EMAIL: padraig.lennon@pioneerinvestments.com
' HISTORY
' VERSION : 1.00 25/06/2009 Initial Development
' Requires : No Requirements at present
'==========================================================================
On Error Resume Next
Dim objShell
Dim typelib,ServerName,boolValid
Dim strLayout,strSize,strLine,intStart,strFail,strCmd
' Set Variables and get the Server Name
Set objShell = WScript.CreateObject("WScript.Shell")
ServerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
' User definable section
strTestName = "winupd" ' Change this to what you want the test column to be.
strAlarmState = "green"
strOutput = ""
Set oShell = WScript.CreateObject("WScript.Shell")
' Check to see If used with BBWin or Big Brother client and set extPath.
extPath = oShell.RegRead("HKLM\SOFTWARE\BBWin\tmpPath")
If extPath = "" Then
extPath = oShell.RegRead("HKLM\SOFTWARE\Quest Software\BigBrother\bbnt\ExternalPath\")
End If
' ========================================
' Main Code Starts Here
strOutput = strOutput & vbcrlf & "<h2>Windows Update Check</h2>" & vbcrlf
Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
If objSysInfo.RebootRequired Then
strAlarmState = "red"
strOutput = strOutput & vbcrlf & "&" & strAlarmState & " Reboot Required to finish applying updates" & vbcrlf & vbcrlf
Else
strAlarmState = "green"
strOutput = strOutput & vbcrlf & "&" & strAlarmState & " All updates applied. NO reboot required" & vbcrlf & vbcrlf
End If
' Write the file for BB
WriteFile extPath, strTestName, strAlarmState, strOutput
'===========================================================
' FUNCTIONS and SUBS start here
' This SUB is used for outputting the file to the external's directory in bbwin
SUB WriteFile(strExtPath, strTestName, strAlarmState, strOutput)
Set fso = CreateObject("Scripting.FileSystemObject")
strOutput = strAlarmState & " " & Date & " " & LCase(Time) & " " & LCase(ServerName) & vbcrlf & strOutput & vbcrlf
Set f = fso.OpenTextFile(strExtPath & "\" & strTestName , 8 , TRUE)
f.Write strOutput
f.Close
Set fso = Nothing
END Sub