(view source code of getres.bat as plain text)
@ECHO OFF
:: No command line parameters pleaseIF NOT [%1]==[] GOTO Syntax
:: Verify OS versionIF NOT "%OS%"=="Windows_NT" GOTO Syntax
:: Keep variables localSETLOCAL
:: Set initial valuesSET VideoCard=
SET XResolution=
SET YResolution=
SET BitsPerPel=
SET VRefresh=
:: Read relevant registry entries and store them in a temporary REG fileREGEDIT /E "%Temp%.\Screen.reg" "HKEY_CURRENT_CONFIG\System\CurrentControlSet\Services"
:: Process the temporary REG fileFOR /F "tokens=* delims=" %%A IN ('TYPE %Temp%.\Screen.reg ^| FIND /V "REGEDIT4" ^| FIND /V ""') DO CALL :Parse01 %%A
:: Display resultsECHO.
SET VideoCard
SET XResolution
SET YResolution
SET BitsPerPel
SET VRefresh
:: Remove temporary fileIF EXIST "%Temp%.\Screen.reg" DEL "%Temp%.\Screen.reg"
:: DoneENDLOCAL
GOTO:EOF
:Parse01:: If this is the second card's entry, and the:: first one was NOT VGA save mode, then quitIF NOT "%VideoCard%"=="" IF NOT "%VideoCard%"=="%NewCard%" IF /I NOT "%VideoCard%"=="VgaSave" GOTO:EOF
:: Read subroutine's command line parameters as one lineSET Line=%*
:: Remove quotes from the lineSET Line=%Line:"=%
:: Remove spaces from the lineSET Line=%Line: =%
:: Check for and parse video card short nameIF "%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 quitIF NOT "%VideoCard%"=="" IF NOT "%VideoCard%"=="%NewCard%" IF /I NOT "%VideoCard%"=="VgaSave" GOTO:EOF
:: If not, then save the new video adapter short nameSET VideoCard=%NewCard%
:: Parse all "key=value" linesFOR /F "tokens=1* delims==" %%A IN ('ECHO.%Line%') DO CALL :Parse02 %%A %%B
:: End of subroutine Parse01GOTO:EOF
:Parse02:: Quit if either key or value aren't specifiedIF "%2"=="" GOTO:EOF
:: %1 is keySET InKey=%1
:: %2 is valueSET InValue=%2
:: Remove "Defaultvalue." prefix from keyFOR /F "tokens=2 delims=." %%a IN ('ECHO.%InKey%') DO SET Key=%%a
:: Continue only for these 4 keys, quit otherwiseIF /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 valueFOR /F "tokens=1,2 delims=:" %%a IN ('ECHO.%InValue%') DO (
SET dWord=%%a
SET xValue=%%b
):: If so, convert hexadecimal value to decimalIF /I "%dWord%"=="dword" (SET /A Value = 0X%xValue%) ELSE (SET Value=%dWord%)
:: Store the resultSET %Key%=%Value%
:: End of subroutine Parse02GOTO:EOF
:SyntaxECHO.
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: 2025-10-11; loaded in 0.0088 seconds