(view source code of hotfixes.vbs as plain text)
' Check command line parameters
Select Case WScript.Arguments.Count
Case 0
' Default if none specified is local computer (".")
Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strComputer = objItem.Name
Next
Case 1
' Command line parameter can either be a computer name
' or "/?" to request online help
strComputer = Wscript.Arguments(0)
if InStr( strComputer, "?" ) > 0 Then Syntax
Case Else
' Maximum is 1 command line parameter
Syntax
End Select
' Header line for screen output
strMsg = vbCrLf & "Hotfixes installed on " & strComputer & ":" & vbCrLf & vbCrLf
' Enable error handling
On Error Resume Next
' Connect to specified computer
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2" )
' Display error number and description if applicable
If Err Then ShowError
' Query hotfixes
Set colQuickFixes = objWMIService.ExecQuery( "Select * from Win32_QuickFixEngineering" )
' Display error number and description if applicable
If Err Then ShowError
' Prepare display of results
For Each objQuickFix in colQuickFixes
strMsg = strMsg _
& " Description: " _
& objQuickFix.Description & vbCrLf _
& " Hot Fix ID: " _
& objQuickFix.HotFixID & vbCrLf _
& " Installation Date: " _
& objQuickFix.InstallDate & vbCrLf _
& " Installed By: " _
& objQuickFix.InstalledBy & vbCrLf & vbCrLf
Next
' Display results
WScript.Echo strMsg
'Done
WScript.Quit(0)
Sub ShowError()
strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & vbCrLf
Syntax
End Sub
Sub Syntax()
strMsg = strMsg & vbCrLf _
& "HotFixes.vbs, Version 1.00" & vbCrLf _
& "List installed hotfixes for any computer on the network" _
& vbCrLf & vbCrLf _
& "Usage: CSCRIPT //NOLOGO HOTFIXES.VBS [ computer_name ]" _
& vbCrLf & vbCrLf _
& "Where: " & Chr(34) & "computer_name" & Chr(34) _
& " is the optional name of a remote computer" & vbCrLf _
& " (default is local computer name)" _
& vbCrLf & vbCrLf _
& "Based entirely on Microsoft TechNet Script " _
& "Center's sample script:" & vbCrLf _
& "http://www.microsoft.com/technet/treeview/default.asp?" _
& "url=/technet/scriptcenter/compmgmt/ScrCM15.asp" _
& vbCrLf & vbCrLf _
& "Modified by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit(1)
End Sub
page last modified: 2024-04-16; loaded in 0.0064 seconds