C:\_G\WWW\~ELISANET\INFO\tscmd175.html
<http://www.elisanet.fi/tsalmi/info/tscmd175.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Tue 11-Dec-2018 17:23:12

 
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.
  C:\_D\TEST>CMDFAQ.CMD
  width_=1440
  height_=900

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

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd175.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd175
http://www.elisanet.fi/tsalmi/info/tscmd175.html
file:///c:/_g/www/~elisanet/info/tscmd175.html