2nd script for checking windows updates with all details

3:48 PM

Wscript.Echo "Hotfix report date: " & Now & vbCrLf


strComputer = "."   ' use "." for local computer


Const HKLM = &H80000002


'On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")



Set colSettings = objWMIService.ExecQuery _
        ("Select * from Win32_OperatingSystem")



' get general info about the OS


' Caption value for different OS:
' Microsoft Windows 2000 ...
' Microsoft Windows XP ...
' Microsoft(R) Windows(R) Server 2003, ..... Edition
For Each objOperatingSystem in colSettings
    strOSCaption = objOperatingSystem.Caption
    Select Case True
      Case InStr(1, strOSCaption, "windows 2000", vbTextCompare) > 0
        strOS = "Windows 2000"
      Case InStr(1, strOSCaption, "windows xp", vbTextCompare) > 0
        strOS = "Windows XP"
      Case InStr(1, strOSCaption, "windows(r) server 2003", vbTextCompare) > 0
        strOS = "Windows Server 2003"
    End Select



    intOSLang = objOperatingSystem.OSLanguage
    strOSLangHex = Right("000" & Hex(intOSLang), 4)
    strOSServicePack = objOperatingSystem.CSDVersion
Next



Set objReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" _
              & strComputer & "/root/default:StdRegProv")



strOSLanguage = "Unknown"  ' Init value
strKeyPath = "SOFTWARE\Classes\MIME\Database\Rfc1766"
strValueName = strOSLangHex
objReg.GetStringValue HKLM, strKeyPath, strValueName, strOSLanguage



' remove unnecessary stuff
arrOSLanguage = Split(strOSLanguage, ";")
strOSLanguage = arrOSLanguage(UBound(arrOSLanguage))
If Instr(strOSLanguage, "(") > 0 Then
    arrOSLanguage = Split(strOSLanguage, "(")
    strOSLanguage = Trim(arrOSLanguage(0))
End If



Wscript.Echo "OS version: " & strOSCaption
Wscript.Echo "SP version: " & strOSServicePack
Wscript.Echo "OS language: " & strOSLanguage



' start enumeration of hotfixes


Wscript.Echo vbCrLf & "Hotfixes Identified:"


strRegBaseUpdate = "SOFTWARE\Microsoft\Updates\" & strOS


Set colItems = objWMIService.ExecQuery _
        ("Select * from Win32_QuickFixEngineering",,48)



For Each objItem in colItems
    If objItem.HotFixID <> "File 1" Then
       Wscript.Echo "HotFixID: " & objItem.HotFixID
       Wscript.Echo "Description: " & objItem.Description
       Wscript.Echo "InstalledBy: " & objItem.InstalledBy
       strInstallDate = Null  ' init value
       If objItem.ServicePackInEffect <> "" Then
          strRegKey = strRegBaseUpdate & "\" & objItem.ServicePackInEffect _
                 & "\" & objItem.HotFixID
          objReg.GetStringValue HKLM, strRegKey, _
               "InstalledDate", strInstallDate
       End If



       If IsNull(strInstallDate) Then
          strInstallDate = "(none found)"
       End If
       Wscript.Echo "InstallDate: " & strInstallDate
       Wscript.Echo   ' blank line
    End If
Next

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results