Screen Resolution revisited



Hi,

I tried Torgeir's scripts today (see below) on a range of video hardware (Intel and ATI) and found the correct information was returned. Very useful!

The only slight oddity, was that the very new Intel chipsets are producing more than one 'item' in the collection and the second item takes about four seconds to retrieve, and then returns 'null' for both horizontal and vertical with both scripts.

I'm guessing this is related to some kind of dual monitor support? It would be good if there was something a bit like wot u get with network adapters where you can set a condition 'Primary=true' to only get the primary display...


'--------------------8<---------------------- strComputer = "." ' use "." for local computer Set objWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")

Set colItems = objWmi.ExecQuery _
     ("Select * from Win32_VideoController")

For Each objItem in colItems
  WScript.Echo objItem.CurrentHorizontalResolution
  WScript.Echo objItem.CurrentVerticalResolution
Next
'--------------------8<----------------------


'--------------------8<---------------------- strComputer = "." ' use "." for local computer Set objWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")

Set colItems = objWmi.ExecQuery _
     ("Select * from Win32_DesktopMonitor")

For Each objItem in colItems
  WScript.Echo objItem.ScreenWidth
  WScript.Echo objItem.ScreenHeight
Next
'--------------------8<----------------------


-- Gerry Hickman (London UK) .



Relevant Pages

  • Re: Enumerate computer names through LDAP
    ... I'm using wbemtest and scriptomatic primarily right now, ... but beyond playing around with the already available scripts, ... >> For each objItem in colItems ...
    (microsoft.public.win32.programmer.wmi)
  • Coding Practices, Best methods?
    ... take most scripts and modify them to fit my needs. ... Set AdRec = CreateObject ... Set AdRec1 = CreateObject ... FOR EACH objItem IN Win32_QuickFixEngineering_colItems ...
    (microsoft.public.scripting.vbscript)
  • C drive name
    ... Unfortunetely all the scripts I see and play with want to look at all ... Dim objWMIService, objItem, colItems, strComputer ... Set objWMIService = GetObject _ ...
    (microsoft.public.scripting.vbscript)
  • Help needed: SWbemRefresher, impersonation, and XP-SP2, WMI
    ... having trouble with all the samples which use the SWbemRefresher object ... It would seem that these scripts are supposed to work, ... use a refresher (always "Invalid Class" on AddEnum line). ... Set colItems = objRefresher.AddEnum _ ...
    (microsoft.public.scripting.vbscript)
  • Re: Scriptomatic
    ... Set colItems = objWMIService.ExecQuery("SELECT * FROM ... For Each objItem In colItems ... is that all the scripts in Scriptomatic should work. ... >> I'm running the scrips, from WinXP. ...
    (microsoft.public.scripting.vbscript)