title: How to Iterate a Registry Folder using Batch Script?
body: <p>I am new to batch scripting.I was trying to write a batch file to iterate through all the string values kept at the registry location <strong>HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders</strong>. And find the result of certain condition. Where the condition is like : a String value with 'Name' field ending with 'Office14'".And I also want to store the 'Name' field of the registry value where the name is ending with 'Office14'.Here is the code which I was using.</p>
  
  <pre><code>    @echo OFF
  
      set KEY_NAME="HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\Folders"
      set OFFICE=OFFICE14\
      set RESULT="NOT FOUND"
  
      FOR %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders"') DO (
         set ValueName=%%A
         REM Getting 9 characters from right i.e OFFICE14\ and comparing it to %OFFICE%
         set ValueName=%ValueName:~-9%
         IF %ValueName%==%OFFICE% (
             set RESULT="FOUND"
             goto :NEXT
         )
      )
      : NEXT
       echo %RESULT%
  </code></pre>
  
  <p>But the result here is always 'Not Found'. Can anybody help me to fix this code or point me to some helpful documentation for doing the same.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: Complete value of name (which ends with Office14) is to be stored in a variable. </p>