Surpress error using for /f reg

February 13, 2009 at 12:21:20
Specs: Vista,XP, na

Hi, I need help with suppressing an error REG not found from a loop. I know that I can redirect errors buy using 2>NUL. In the code section I have pasted,the 2>NUL part breaks the script. Any idea on what the correct syntax should be. The script does work without the 2>nul

thank you


echo off
set OutlookProfileReady="No"

for /f "tokens=1,*" %%a in ('reg query HKCU\Software\Microsoft\Office\12.0\Outlook\Setup /v First-Run 2>nul ^|find "First-Run"') do (set OutlookProfileReady=%%a)
if %OutlookProfileReady%==First-Run goto Endofloop
goto StartLoop

echo First-Run Registry Key found !


See More: Surpress error using for /f reg

Report •

February 13, 2009 at 14:00:44
You need to escape the redirection symbol using a carat ^. The same goes for <,>,^ & | (yes the carat can escape itself). This way the function on the special character doesn't get executed until the command within the "in" part of the for loop is executed.

Report •
Related Solutions

Ask Question