Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for videorom.vbs

(view source code of videorom.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
  12. 		' name or "/?" to request online help
  13. 		strComputer = UCase( 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. ' Header line for screen output
  21. strMsg = vbCrLf & "Video summary for " & strComputer & ":" & vbCrLf & vbCrLf
  22.  
  23. ' Enable error handling
  24. On Error Resume Next
  25.  
  26. ' Connect to specified computer
  27. Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
  28. ' Display error number and description if applicable
  29. If Err Then ShowError
  30.  
  31. ' Query video adapter properties
  32. Set colItems = objWMIService.ExecQuery( "Select * from Win32_VideoController", , 48 )
  33. ' Display error number and description if applicable
  34. If Err Then ShowError
  35.  
  36. ' Prepare display of results
  37. For Each objItem in colItems
  38. 	strMsg = strMsg _
  39. 	       & "    Name:                    " _
  40. 	       & objItem.Name & vbCrLf _
  41. 	       & "    Description:             " _
  42. 	       & objItem.Description & vbCrLf _
  43. 	       & "    Video Processor:         " _
  44. 	       & objItem.VideoProcessor & vbCrLf _
  45. 	       & "    Adapter RAM:             " _
  46. 	       & Int( ( objItem.AdapterRAM + 524288 ) / 1048576 ) _
  47. 	       & " MB" & vbCrLf _
  48. 	       & "    Video Mode Description:  " _
  49. 	       & objItem.VideoModeDescription & vbCrLf & vbCrLf
  50. Next
  51.  
  52. ' Display results
  53. WScript.Echo strMsg
  54.  
  55. 'Done
  56. WScript.Quit(0)
  57.  
  58.  
  59. Sub ShowError()
  60. 	strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
  61. 	         Err.Description & vbCrLf & vbCrLf
  62. 	Syntax
  63. End Sub
  64.  
  65.  
  66. Sub Syntax()
  67. 	strMsg = strMsg & vbCrLf _
  68. 	       & "VideoROM.vbs,  Version 1.00" & vbCrLf _
  69. 	       & "Display video adapter summary for any WMI " _
  70. 	       & "enabled computer on the network" _
  71. 	       & vbCrLf & vbCrLf _
  72. 	       & "Usage:  CSCRIPT  VIDEOROM.VBS  [ computer_name ]" _
  73. 	       & vbCrLf & vbCrLf _
  74. 	       & "Where:  " & Chr(34) & "computer_name" & Chr(34) _
  75. 	       & " is the optional name of a remote" & vbCrLf _
  76. 	       & "        computer (default is local computer name)" _
  77. 	       & vbCrLf & vbCrLf _
  78. 	       & "Written by Rob van der Woude" & vbCrLf _
  79. 	       & "http://www.robvanderwoude.com" _
  80. 	       & vbCrLf & vbCrLf _
  81. 	       & "Created with Microsoft's Scriptomatic tool" & vbCrLf _
  82. 	       & "http://www.microsoft.com/technet/treeview/default.asp" _
  83. 	       & "?url=/technet/scriptcenter/WMImatic.asp" & vbCrLf
  84. 	WScript.Echo strMsg
  85. 	WScript.Quit(1)
  86. End Sub
  87.  

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