Powered by GeSHi

Source code for bios.vbs

(view source code of bios.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. On Error Resume Next
  21. ' Connect to computer's WMI service
  22. Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
  23. ' Display error number and description if applicable
  24. If Err.Number Then ShowError()
  25.  
  26. ' Collect BIOS information
  27. Set colItems = objWMIService.ExecQuery( "Select * from Win32_BIOS where PrimaryBIOS = true", , 48 )
  28. ' Display error number and description if applicable
  29. If Err.Number Then ShowError()
  30.  
  31. ' Initialize screen output variable
  32. strMsg = vbCrLf & "BIOS summary for " & strComputer & ":" & vbCrLf
  33.  
  34. ' Prepare collected info for display
  35. For Each objItem in colItems
  36. 	strMsg = strMsg _
  37. 	       & "    BIOS Name       :  " & objItem.Name & vbCrLf _
  38. 	       & "    Version         :  " & objItem.Version & vbCrLf _
  39. 	       & "    Manufacturer    :  " & objItem.Manufacturer & vbCrLf _
  40. 	       & "    SMBIOS Version  :  " & objItem.SMBIOSBIOSVersion & vbCrLf
  41. Next
  42.  
  43. ' Display the results
  44. WScript.Echo strMsg
  45.  
  46. ' Done
  47. WScript.Quit(0)
  48.  
  49.  
  50. Sub ShowError
  51. 	strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
  52. 	         Err.Description & vbCrLf & vbCrLf
  53. 	Syntax
  54. End Sub
  55.  
  56.  
  57. Sub Syntax
  58. 	strMsg = strMsg & vbCrLf & "BIOS.vbs,  Version 1.00" & vbCrLf & _
  59. 	         "Display BIOS information." & vbCrLf & vbCrLf & _
  60. 	         "Usage:  CSCRIPT  BIOS.VBS  [ computer_name ]" & _
  61. 	         vbCrLf & vbCrLf & _
  62. 	         "Where:  " & Chr(34) & "computer_name" & Chr(34) & _
  63. 	         " is the name of a WMI enabled computer on the network" & _
  64. 	         vbCrLf & vbCrLf & _
  65. 	         "Written by Rob van der Woude" & vbCrLf & _
  66. 	         "http://www.robvanderwoude.com" & vbCrLf & vbCrLf & _
  67. 	         "Created using Microsoft's Scriptomatic tool" & vbCrLf & _
  68. 	         "http://www.microsoft.com/technet/treeview/default.asp?" & _
  69. 	         "url=/technet/scriptcenter/WMImatic.asp" & vbCrLf
  70. 	WScript.Echo strMsg
  71. 	' Abort with return code 1
  72. 	WScript.Quit(1)
  73. End Sub
  74.