(view source code of getvideo.bat as plain text)
@ECHO OFF
IF NOT "%~1"=="" GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
REG.EXE Query "HKLM\SYSTEM\ControlSet001\Control" | FIND.EXE "\MiniNT" >NUL 2>&1
IF ERRORLEVEL 1 (CALL :RegularWindows) ELSE (CALL :WinPE 2>NUL)
ENDLOCAL
GOTO:EOF
:GetWinDrive
SET WinDrive=
FOR /F "tokens=2 delims==" %%A IN ('WMIC.EXE Path Win32_LogicalDisk Get DeviceID /Value') DO (
REM Stop at the first Windows drive found, the last one is usually the WinPE boot disk
IF "!WinDrive!"=="" (
FOR %%B IN (%%A) DO (
IF EXIST %%~B\windows\system32\config\system SET WinDrive=%%~B
)
)
)
GOTO:EOF
:OnError
START REGEDIT.EXE
ECHO An error occurred while trying to %1 an external registry hive.
ECHO Please use REGEDIT to check if HKEY_LOCAL_MACHINE\TempHive exists.
ECHO If it does, open a CMD Prompt as Administrator, and run the command:
ECHO.
ECHO REG Unload HKLM\TempHive
ECHO.
ECHO Press any key when done . . .
PAUSE >NUL
GOTO:EOF
:RegularWindows
SET ComputerName
SET Count=0
FOR /F "tokens=1* delims==" %%A IN ('WMIC.EXE Path Win32_VideoController Get AdapterRAM^,Name /Value') DO (
FOR %%C IN ("%%~B") DO (
SET VideoCard[!Count!].%%A=%%~C
IF DEFINED VideoCard[!Count!].Name SET /A Count += 1
)
)
SET VideoCard
GOTO:EOF
:WinPE
CALL :GetWinDrive
IF "%WinDrive%"=="" GOTO:EOF
REG.EXE Load HKLM\TempHive %WinDrive%\windows\system32\config\system >NUL 2>&1
IF ERRORLEVEL 1 (
CALL :OnError load
GOTO:EOF
)
FOR /F "tokens=3" %%C IN ('REG.EXE Query HKLM\TempHive\ControlSet001\Control\ComputerName\ComputerName /V ComputerName /T REG_SZ ^| FIND.EXE "REG_SZ"') DO SET ComputerName=%%C
SET Count=0
FOR /F %%C IN ('REG.EXE Query HKLM\TempHive\ControlSet001\Control\Class ^| FIND.EXE "HKEY_"') DO (
REG.EXE Query "%%~C" /V "Class" /T REG_SZ | FIND.EXE /I " Display" >NUL 2>&1
IF NOT ERRORLEVEL 1 (
FOR /F "tokens=*" %%D IN ('REG.EXE Query "%%~C" ^| FIND.EXE "HKEY_"') DO (
FOR /F "tokens=2*" %%E IN ('REG.EXE Query "%%~D" /V "DriverDesc" /T REG_SZ 2^>NUL ^| FIND.EXE "REG_SZ" ^|^| REG.EXE Query "%%~D" /V "DriverDesc" /T REG_SZ ^| FIND.EXE "REG_SZ"') DO SET VideoCard[!Count!].Name=%%F
FOR /F "tokens=2*" %%E IN ('REG.EXE Query "%%~D" /V "HardwareInformation.MemorySize" /T REG_DWORD ^| FIND.EXE "REG_DWORD"') DO SET /A VideoCard[!Count!].AdapterRAM=%%F
SET /A Count += 1
)
)
)
REG.EXE Unload HKLM\TempHive >NUL 2>&1
IF ERRORLEVEL 1 (
CALL :OnError unload
GOTO:EOF
)
SET ComputerName
SET VideoCard
GOTO:EOF
:Syntax
ECHO.
ECHO GetVideo.bat, Version 1.01
ECHO Display the video card^(s^) model^(s^) and memory size^(s^)
ECHO.
ECHO Usage: GETVIDEO.BAT
ECHO.
ECHO This batch file uses WMIC when running in a "regular" Windows environment;
ECHO if it detects a Windows PE environment, where WMIC won't return video card
ECHO info, the batch file will mount the computer's HKLM registry hive, search
ECHO for the video card info, and dismount the temporary registry hive.
ECHO Screen output is identical in "regular" Windows and WinPE.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0072 seconds