Q. How can I view information about my system monitors?

John Savill

March 11, 2008

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The Win32_DesktopMonitor class, which is accessible through Windows Management Instrumentation (WMI), gives information about system monitors. The class is documented at "Win32_DesktopMonitor Class."

The following WMI script (showmonitors.vbs) lists all the connected monitors in my network.

strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim WshShell
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colMonitors = objWMIService.ExecQuery ("select * from win32_DesktopMonitor where Availability = 3")
For Each objMonitor in colMonitors
wscript.echo "Caption " & objMonitor.Caption
wscript.echo "Resolution " & objMonitor.ScreenWidth & " x " & objMonitor.ScreenHeight
wscript.echo "Availability " & objMonitor.Availability
Next

Note that the availability value specifies the monitor state. In my example, monitor 3 is in operation (the other values are documented in the previously referenced MSDN article).

To run the script, enter the command

D:Temp>cscript showmonitors.vbs

The following is the result:

Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Caption Dell 2407WFP (Digital)
Resolution 1920 x 1200
Availability 3

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like