Search notes:

regQuery.bat

regQuery.bat allows to query the value under a specific registry key in cmd.exe.
The following invocation queries the registry value OS under the queried key:
C:\> "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" OS
Windows_NT

regQuery.bat

@rem
@rem Usage:
@rem
@rem   regQuery  HKCU\Environment PATH
@rem   regQuery "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" TEMP
@rem

@set key=%1
@set val=%2

@if [%key%] equ [] goto usage
@if [%val%] equ [] goto usage

@rem
@rem Use skip=2 because reg query prints an empty line first.
@rem Use tokens=2,* because req query also prints value name and its data type which
@rem we don't want to be printed.
@rem

@for /f "skip=2 tokens=2,*" %%a in ('reg query %key% /v %val%') do @echo %%b

@exit /b 0

:usage
@echo.
@echo.   reqQuery registryKey ValueUnderThisKey
@echo.
Github repository scripts-and-utilities, path: /regQuery.bat

See also

regat.bat can be used in cmd.exe to open the registry (regedit.exe) at a given key.
reg.exe.
Other scripts.

Index