We were needing a method of querying systems to determine if they had a specific registry key enabled. In our case, we wanted to verify smart card access. Here is a working script that will tell you yes or no based on the exit code. Essentially, we are reading the registry, convering it to a single digit value, transferring that into system variable, re-reading that as an exit code, and outputting that to DS / NS. From here, you have a working template that you can customize to read nearly any registry value you desire.
@echo off for /f "tokens=*" %%a in ('"REG QUERY HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v scforceoption"') do set REGVAR=%%a set REGVAR=%REGVAR:~-1% IF %REGVAR% == 0 GOTO SCOFF IF %REGVAR% == 1 GOTO SCON GOTO EXIT :SCOFF exit 10001 GOTO EXIT :SCON exit 10002 GOTO EXIT :EXIT exit 10003