title: FOR tokens batch command can't hide error "ERROR: The system was unable to find..."
body: <p>I'm doing a simple script to check MS Office version reading registry key value. Will be scenarios where the key won't exist (not office installed) I used many times reg.exe query KEY/Check 2>nul but can't make that work inside a FOR line. 
  This is the line:</p>
  
  <pre><code>FOR /f "tokens=3" %%a in ('%SystemRoot%\System32\reg.exe query "HKEY_CLASSES_ROOT\Word.Application\CurVer" ^| %SystemRoot%\System32\findstr /C:"(Default)"') do set _Off_ver=%%a
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>FOR /f "tokens=3" %%a in ('%SystemRoot%\System32\reg.exe query "HKEY_CLASSES_ROOT\Word.Application\CurVer" 2&gt;nul ^| %SystemRoot%\System32\findstr /C:"(Default)"') do set _Off_ver=%%a
  </code></pre>
  
  <p>or</p>
  
  <pre><code>FOR /f "tokens=3" %%a in ('%SystemRoot%\System32\reg.exe query "HKEY_CLASSES_ROOT\Word.Application\CurVer" ^| %SystemRoot%\System32\findstr /C:"(Default)"'2&gt;nul ) do set _Off_ver=%%a
  </code></pre>
  
  <p>and in many other places but I end up with the error:</p>
  
  <pre><code>&gt; was unexpected at this time.
  </code></pre>
  
  <p>Anyone know how I can hide the error: </p>
  
  <pre><code>ERROR: The system was unable to find the specified registry key or value.
  </code></pre>
  
  <p>Inside that FOR Line? </p>
  
  <p>THANKS</p>