Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Tue 6-Apr-2010 18:14:16

Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.

175} How do I get the current video display resolution?

  @echo off & setlocal enableextensions
  :: Build a Visual Basic Script

  set skip=
  set vbs_=%temp%\tmp$$$.vbs
  findstr "'%skip%VBS" "%~f0" > "%vbs_%"
  :: Run the script with Microsoft Windows Script Host Version 5.6

  for /f "tokens=1,2" %%a in ('cscript //nologo "%vbs_%"') do (
    set width_=%%a
    set height_=%%b)
  :: Display the results

  echo width_=%width_%
  echo height_=%height_%
  :: Clean up

  for %%f in ("%vbs_%") do if exist %%f del %%f
  if not defined cmdbox if defined PauseIfFromDesktop pause
  endlocal & goto :EOF
  On Error Resume Next 'VBS
  Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") 'VBS
  Set colItems = objWMIService.ExecQuery ("Select * from Win32_DisplayConfiguration") 'VBS
  For Each objItem in colItems 'VBS
    WScript.StdOut.Write objItem.PelsWidth 'VBS
    WScript.StdOut.Write " " & objItem.PelsHeight 'VBS
    WScript.StdOut.WriteLine 'VBS
  Next 'VBS

The output could be e.g.

    Microsoft Technet Script Center: Script Repository: Video and Display: List Current Display Configuration Values