Query the windows registry

I had the need to query the registry for a specific string, if the string is found or not then engage an action.

Within this scenario as example, it query the registry and a specified string, an action is taken if this one is not found/present.

 

@ECHO OFF
set regpath=HKLM\Software\Microsoft\xx\
set regvalue=mystring
set regdata=1
reg query "%regpath%" /v "%regvalue%" | find /i "%regdata%"
if errorlevel 1 (
      echo Please wait blah blah......
      Start /WAIT .\myprog\install.exe
      EXIT /B /0
)