title: Get maximum supported resolution of all attached monitors
body: <p>I'm trying to get the maximum supported resolution of both of my monitors using WMI (since it will be part of a VBScript)I've tried the following WMI commands, but I either get a wrong result or only get info for one monitor.</p>
  
  <pre><code>C:\&gt;wmic path win32_videocontroller get videomodedescription /format:list
  VideoModeDescription=1366 x 768 x 4294967296 colors
  
  C:\&gt;wmic path win32_displaycontrollerconfiguration get videomode /format:list
  VideoMode=1024 by 768 pixels, True Color, 60 Hertz
  </code></pre>
  
  <p>According to Display Settings, my laptop monitor is 1366x768... No clue where WMI is getting 1024x768 from. Plus, if I change the resolution of my laptop monitor is Display Settings to 800x600, I get this:</p>
  
  <pre><code>C:\&gt;wmic path win32_videocontroller get videomodedescription
  VideoModeDescription=800 x 600 x 4294967296 colors
  </code></pre>
  
  <p>So the command that is accurately reporting my current resolution is not telling me what my maximum resolution is. (I don't care if dumb end users are turning their resolution down, I just want to know what resolution their monitor is capable of supporting.)</p>
  
  <p>As you can see, none of these methods so far has shown me any information about the external monitor I also have attached to my laptop. If I use <code>Win32_DesktopMonitor</code>, I get all kinds of info about the external monitor, but not its resolution.</p>
  
  <pre><code>C:\&gt;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&amp;amp;298A3A3E&amp;amp;0&amp;amp;UID16843008
  PowerManagementCapabilities=
  PowerManagementSupported=
  ScreenHeight=
  ScreenWidth=
  Status=OK
  StatusInfo=
  SystemCreationClassName=Win32_ComputerSystem
  </code></pre>
  
  <p>So, is there a way using VBScript (either via WMI or not) to get the maximum supported resolution of every attached monitor?</p>
  
  <hr>
  
  <p>Update: I just ran this against a remote machine where the user has an external monitor plugged directly into their laptop, whereas mine is plugged into a docking station.</p>
  
  <pre><code>C:\&gt;winrs -r:remotehostname wmic path win32_videocontroller get videomodedescription
  
  VideoModeDescription
  1920 x 1080 x 4294967296 colors
  1440 x 900 x 4294967296 colors
  </code></pre>
  
  <hr>
  
  <p>Upated 2: Using <a href="https://wmie.codeplex.com/" rel="nofollow noreferrer">WMI Explorer</a> I found this command which displays every supported mode. The output is far too long to post, but I've included the output for one supported mode.</p>
  
  <pre><code>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
  </code></pre>
  
  <p><code>HorizontalActivePixels</code> and <code>VerticalActivePixels</code> give me the dimensions I'm looking for. There are two instances of the <code>WmiMonitorListedSupportedSourceModes</code> class, one for each monitor. Now the question is how to look through the <code>MonitorSourceModes</code> array to find the max resolution for each instance. :(</p>
  
  <hr>
  
  <p>For anyone looking for the VBScript equivalent to @<a href="https://stackoverflow.com/users/478656/tessellatingheckler">TessellatingHeckler</a>'s excellent PowerShell answer:</p>
  
  <pre><code>strComputer = "."
  
  strQuery = "SELECT PreferredMonitorSourceModeIndex, MonitorSourceModes " &amp; _
             "FROM WmiMonitorListedSupportedSourceModes"
  
  Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer &amp; "\ROOT\WMI")
  Set colItems = objWMIService.ExecQuery(strQuery, , 48)
  
  For Each objItem In colItems
      intIndex = objItem.PreferredMonitorSourceModeIndex
      Wscript.StdOut.WriteLine "InstanceName: " &amp; _
          objItem.InstanceName
      Wscript.StdOut.WriteLine "Horizontal: " &amp; _
          objItem.MonitorSourceModes(intIndex).HorizontalActivePixels
      Wscript.StdOut.WriteLine "Vertical: " &amp; _
          objItem.MonitorSourceModes(objIintIndex).VerticalActivePixels
      Wscript.StdOut.WriteLine "__________"
  Next
  </code></pre>