[batch-file] How can I get the value of a registry key from within a batch script?

With regedit:

@echo off
setlocal
::if the scrit is not ran as administrator
::  and the key does not require admin permissions
set __COMPAT_LAYER=RunAsInvoker

set "key=%~1"
set "value=%~2"

regedit /e "#.reg" "%key%"


for /f "tokens=1,* delims==" %%a in ('find  """%value%""=" "#.reg"') do if "%%~b" neq "" echo %%~b
del /q #.reg

endlocal

Example:

call regreader.bat "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\1033\" Version

output:

3.0.30729.4926