(view source code of getres.bat as plain text)
@ECHO OFF
:: No command line parameters please
IF NOT [%1]==[] GOTO Syntax
:: Verify OS version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
:: Keep variables local
SETLOCAL
:: Set initial values
SET VideoCard=
SET XResolution=
SET YResolution=
SET BitsPerPel=
SET VRefresh=
:: Read relevant registry entries and store them in a temporary REG file
REGEDIT /E "%Temp%.\Screen.reg" "HKEY_CURRENT_CONFIG\System\CurrentControlSet\Services"
:: Process the temporary REG file
FOR /F "tokens=* delims=" %%A IN ('TYPE %Temp%.\Screen.reg ^| FIND /V "REGEDIT4" ^| FIND /V ""') DO CALL :Parse01 %%A
:: Display results
ECHO.
SET VideoCard
SET XResolution
SET YResolution
SET BitsPerPel
SET VRefresh
:: Remove temporary file
IF EXIST "%Temp%.\Screen.reg" DEL "%Temp%.\Screen.reg"
:: Done
ENDLOCAL
GOTO:EOF
:Parse01
:: If this is the second card's entry, and the
:: first one was NOT VGA save mode, then quit
IF NOT "%VideoCard%"=="" IF NOT "%VideoCard%"=="%NewCard%" IF /I NOT "%VideoCard%"=="VgaSave" GOTO:EOF
:: Read subroutine's command line parameters as one line
SET Line=%*
:: Remove quotes from the line
SET Line=%Line:"=%
:: Remove spaces from the line
SET Line=%Line: =%
:: Check for and parse video card short name
IF "%Line:~0,6%"=="[HKEY_" FOR /F "tokens=5 delims=\]" %%A IN ('ECHO.%Line%') DO IF NOT "%%A"=="" SET NewCard=%%A
:: If this is the second card's entry, and the
:: first one was NOT VGA save mode, then quit
IF NOT "%VideoCard%"=="" IF NOT "%VideoCard%"=="%NewCard%" IF /I NOT "%VideoCard%"=="VgaSave" GOTO:EOF
:: If not, then save the new video adapter short name
SET VideoCard=%NewCard%
:: Parse all "key=value" lines
FOR /F "tokens=1* delims==" %%A IN ('ECHO.%Line%') DO CALL :Parse02 %%A %%B
:: End of subroutine Parse01
GOTO:EOF
:Parse02
:: Quit if either key or value aren't specified
IF "%2"=="" GOTO:EOF
:: %1 is key
SET InKey=%1
:: %2 is value
SET InValue=%2
:: Remove "Defaultvalue." prefix from key
FOR /F "tokens=2 delims=." %%a IN ('ECHO.%InKey%') DO SET Key=%%a
:: Continue only for these 4 keys, quit otherwise
IF /I NOT "%Key%"=="BitsPerPel" IF /I NOT "%Key%"=="XResolution" IF /I NOT "%Key%"=="YResolution" IF /I NOT "%Key%"=="VRefresh" GOTO:EOF
:: Parse value to check if it is a dword value
FOR /F "tokens=1,2 delims=:" %%a IN ('ECHO.%InValue%') DO (
SET dWord=%%a
SET xValue=%%b
)
:: If so, convert hexadecimal value to decimal
IF /I "%dWord%"=="dword" (SET /A Value = 0X%xValue%) ELSE (SET Value=%dWord%)
:: Store the result
SET %Key%=%Value%
:: End of subroutine Parse02
GOTO:EOF
:Syntax
ECHO.
ECHO GetRes.bat, Version 3.00 for Windows NT 4 / 2000
ECHO Read and display video resolution settings from the registry
ECHO.
ECHO Usage: GETRES
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
ECHO.
page last modified: 2024-04-16; loaded in 0.0107 seconds