Get the maximum supported resolution of all connected monitors

I am trying to get the maximum supported resolution of both of my monitors using WMI (since this will be part of VBScript). I tried the following WMI commands, but I am either mistaken or getting information for a single monitor.

C:\>wmic path win32_videocontroller get videomodedescription /format:list
VideoModeDescription=1366 x 768 x 4294967296 colors

C:\>wmic path win32_displaycontrollerconfiguration get videomode /format:list
VideoMode=1024 by 768 pixels, True Color, 60 Hertz

According to the display settings, my laptop monitor is 1366x768 ... I don’t know where WMI gets 1024x768. Plus, if I change the resolution of my laptop monitor, these are screen settings to 800x600, I get the following:

C:\>wmic path win32_videocontroller get videomodedescription
VideoModeDescription=800 x 600 x 4294967296 colors

So, the command that accurately reports my current resolution does not tell me what my maximum resolution is. (I don't care if deaf end users turn their resolution down, I just want to know what resolution their monitor is capable of supporting.)

, , . Win32_DesktopMonitor, , .

C:\>wmic path win32_desktopmonitor get /format:list

Availability=8
Bandwidth=
Caption=HP L1710 LCD Monitor
ConfigManagerErrorCode=0
ConfigManagerUserConfig=FALSE
CreationClassName=Win32_DesktopMonitor
Description=HP L1710 LCD Monitor
DeviceID=DesktopMonitor1
DisplayType=
ErrorCleared=
ErrorDescription=
InstallDate=
IsLocked=
LastErrorCode=
MonitorManufacturer=Hewlett-Packard
MonitorType=HP L1710 LCD Monitor
Name=HP L1710 LCD Monitor
PixelsPerXLogicalInch=96
PixelsPerYLogicalInch=96
PNPDeviceID=DISPLAY\HWP26EB\4&298A3A3E&0&UID16843008
PowerManagementCapabilities=
PowerManagementSupported=
ScreenHeight=
ScreenWidth=
Status=OK
StatusInfo=
SystemCreationClassName=Win32_ComputerSystem

, VBScript ( WMI, ), ?


: , , , -.

C:\>winrs -r:remotehostname wmic path win32_videocontroller get videomodedescription

VideoModeDescription
1920 x 1080 x 4294967296 colors
1440 x 900 x 4294967296 colors

2: WMI Explorer , . , .

wmic /namespace:\\ROOT\WMI path WmiMonitorListedSupportedSourceModes get MonitorSourceModes /format:list

__PATH=
__NAMESPACE=
__SERVER=
__DERIVATION={}
__PROPERTY_COUNT=28
__RELPATH=
__DYNASTY=VideoModeDescriptor
__SUPERCLASS=
__CLASS=VideoModeDescriptor
__GENUS=2
CompositePolarityType = 2
HorizontalActivePixels = 1366
HorizontalBlankingPixels = 160
HorizontalBorder = 0
HorizontalImageSize = 310
HorizontalPolarityType = 1
HorizontalRefreshRateDenominator = 763
HorizontalRefreshRateNumerator = 24100000
HorizontalSyncOffset = 48
HorizontalSyncPulseWidth = 32
IsInterlaced = False
IsSerrationRequired = 2
IsSyncOnRGB = 2
Origin = 2
PixelClockRate = 48200000
StereoModeType = 0
SyncSignalType = 3
TimingType = 4
VerticalActivePixels = 768
VerticalBlankingPixels = 22
VerticalBorder = 0
VerticalImageSize = 174
VerticalPolarityType = 1
VerticalRefreshRateDenominator = 60277
VerticalRefreshRateNumerator = 2410000
VerticalSyncOffset = 3
VerticalSyncPulseWidth = 5
VideoStandardType = 0

HorizontalActivePixels VerticalActivePixels , . WmiMonitorListedSupportedSourceModes, . , MonitorSourceModes, .: (


, VBScript @TessellatingHeckler PowerShell:

strComputer = "."

strQuery = "SELECT PreferredMonitorSourceModeIndex, MonitorSourceModes " & _
           "FROM WmiMonitorListedSupportedSourceModes"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\ROOT\WMI")
Set colItems = objWMIService.ExecQuery(strQuery, , 48)

For Each objItem In colItems
    intIndex = objItem.PreferredMonitorSourceModeIndex
    Wscript.StdOut.WriteLine "InstanceName: " & _
        objItem.InstanceName
    Wscript.StdOut.WriteLine "Horizontal: " & _
        objItem.MonitorSourceModes(intIndex).HorizontalActivePixels
    Wscript.StdOut.WriteLine "Vertical: " & _
        objItem.MonitorSourceModes(objIintIndex).VerticalActivePixels
    Wscript.StdOut.WriteLine "__________"
Next
+4
1

PowerShell. , , ... VBScript.

# WmiMonitorId gives the make/model details
$IDs = gwmi -NameSpace "root\wmi" -Class WmiMonitorId

# This gives the available resolutions
$monitors = gwmi -N "root\wmi" -Class WmiMonitorListedSupportedSourceModes 


$results = foreach($monitor in $monitors) {
    # Get the id for this monitor
    $currentId =  $IDs |? {$_.InstanceName -eq $Monitor.InstanceName}

    # Sort the available modes by display area (width*height)
    $sortedModes = $monitor.MonitorSourceModes | sort -property {$_.HorizontalActivePixels * $_.VerticalActivePixels}
    $maxModes = $sortedModes | select @{N="MaxRes";E={"$($_.HorizontalActivePixels)x$($_.VerticalActivePixels)"}}

    # Tidy output - convert [uint16[]] name value to text, and pick the max res
    [pscustomobject]@{
        Name=($currentId.UserFriendlyName | % {[char]$_}) -join ''
        Modes=($maxModes | select -last 1).MaxRes
        YearOfManufacture=$currentId.YearOfManufacture
        WeekOfManufacture=$currentId.WeekOfManufacture
    }
}

$results

( NB ).

:

Name        MaxRes
----        ----
HP xyz      1080x720
HP abc      1920x1080
+2

All Articles