Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for hotfixestd.vbs

(view source code of hotfixestd.vbs as plain text)

  1. ' Check command line parameters
  2. Select Case WScript.Arguments.Count
  3. 	Case 0
  4. 		' Default if none specified is local computer (".")
  5. 		Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
  6. 		Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
  7. 		For Each objItem in colItems
  8. 			strComputer = objItem.Name
  9. 		Next
  10. 	Case 1
  11. 		' Command line parameter can either be a computer name
  12. 		' or "/?" to request online help
  13. 		strComputer = Wscript.Arguments(0)
  14. 		if InStr( strComputer, "?" ) > 0 Then Syntax
  15. 	Case Else
  16. 		' Maximum is 1 command line parameter
  17. 		Syntax
  18. End Select
  19.  
  20. ' Set header for screen output
  21. strMsg = vbCrLf _
  22.        & "Hot Fix ID:" & vbTab _
  23.        & "Description:" & vbTab _
  24.        & "Installation Date:" & vbTab _
  25.        & "Installed By:" & vbCrLf
  26.  
  27. ' Enable error handling
  28. On Error Resume Next
  29.  
  30. ' Connect to specified computer
  31. Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2" )
  32. ' Display error number and description if applicable
  33. If Err Then ShowError
  34.  
  35. ' Query hotfixes
  36. Set colQuickFixes = objWMIService.ExecQuery( "Select * from Win32_QuickFixEngineering" )
  37. ' Display error number and description if applicable
  38. If Err Then ShowError
  39.  
  40. ' Prepare display of results
  41. For Each objQuickFix in colQuickFixes
  42. 	strMsg = strMsg _
  43. 	       & objQuickFix.HotFixID & vbTab _
  44. 	       & objQuickFix.Description & vbTab _
  45. 	       & objQuickFix.InstallDate & vbTab _
  46. 	       & objQuickFix.InstalledBy & vbCrLf
  47. Next
  48.  
  49. ' Display results
  50. WScript.Echo strMsg
  51.  
  52. 'Done
  53. WScript.Quit(0)
  54.  
  55.  
  56. Sub ShowError()
  57. 	strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
  58. 	         Err.Description & vbCrLf & vbCrLf
  59. 	Syntax
  60. End Sub
  61.  
  62.  
  63. Sub Syntax()
  64. 	strMsg = strMsg & vbCrLf _
  65. 	       & "HotFixesTD.vbs,  Version 1.00" & vbCrLf _
  66. 	       & "List installed hotfixes for any computer on the network " _
  67. 	       & "in tab delimited format" & vbCrLf & vbCrLf _
  68. 	       & "Usage:  CSCRIPT  //NOLOGO  HOTFIXESTD.VBS  " _
  69. 	       & "[ computer_name ]" & vbCrLf & vbCrLf _
  70. 	       & "Where:  " & Chr(34) & "computer_name" & Chr(34) _
  71. 	       & " is the optional name of a remote computer" & vbCrLf _
  72. 	       & "                        (default is local computer name)" _
  73. 	       & vbCrLf & vbCrLf _
  74. 	       & "Based entirely on Microsoft TechNet Script " _
  75. 	       & "Center's sample script:" & vbCrLf _
  76. 	       & "http://www.microsoft.com/technet/treeview/default.asp?" _
  77. 	       & "url=/technet/scriptcenter/compmgmt/ScrCM15.asp" _
  78. 	       & vbCrLf & vbCrLf _
  79. 	       & "Modified by Rob van der Woude" & vbCrLf _
  80. 	       & "http://www.robvanderwoude.com"
  81. 	WScript.Echo strMsg
  82. 	WScript.Quit(1)
  83. End Sub
  84.  

page last modified: 2024-04-16; loaded in 0.0082 seconds