VBScript - get permission of the main monitor

I need to get the current main screen resolution using VBScript. There is a start menu on the main display.

I checked:

  • Array from Win32_VideoSettings contains 0 elements

  • Array from Win32_VideoConfiguration contains 0 elements

  • The array from Win32_VideoController always has one element - even if a second monitor is connected

How can I get the resolution of the currently installed main screen ?

+3
source share
1 answer
'Author: Demon
'Website: http://demon.tw
'Date: 2012/5/7
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)

For Each objItem in colItems
    WScript.Echo "ScreenHeight: " & objItem.ScreenHeight
    WScript.Echo "ScreenWidth: " & objItem.ScreenWidth
Next
+3
source

All Articles