Monday, August 11, 2014

Windows batch script to lookup a value or key in Registry

Find... method in RegEdit is a little tedious to use on Windows platform cauze it is looking for one instance of a search key at a time (you have to hit "Next" to get the next search result).

We could instead do the global search by the following script (regrep.bat) in command line:

@echo off
for %%a in (HKLM HKCU HKCR HKU HKCC) do (
  echo [Regrep] Looking for reg value under path %%a
  reg query %%a /f %1 /s
)
 
which could find the search term under all path recursively.
 
e.g.
 
Find a single term:
  regrep system32
 
Find a word with space
  regrep "internet explorer"