How to Redirect error to pipe not File, eg 2| not 2>
Posted: 30 Apr 2010 08:19
I would like to do this, but it crashes :-
is there a simple fix please ?
This code works, but is clumsy :-
The problem is that REG.EXE is STUPID and it sets ERRORLEVEL in an idiotic manner.
It assumes no error if there is any message delivered on stream 1
and disregards error messages which may "simultaneously" occur on stream 2,
hence I direct error messages to TT2.TXT, and FIND gives an accurate ERRORLEVEL,
Then I have to preserve that in GOODERROR for use after I get rid of TT2.TXT
Regards
Alan
Code: Select all
REG QUERY %REGISTRY_KEY% > NUL 2| FIND " " > NUL
is there a simple fix please ?
This code works, but is clumsy :-
Code: Select all
REG QUERY %REGISTRY_KEY% > NUL 2> TT2.TXT
FIND " " < TT2.TXT > NUL
SET /A GOODERROR=%ERRORLEVEL%
DEL TT2.TXT
The problem is that REG.EXE is STUPID and it sets ERRORLEVEL in an idiotic manner.
It assumes no error if there is any message delivered on stream 1
and disregards error messages which may "simultaneously" occur on stream 2,
hence I direct error messages to TT2.TXT, and FIND gives an accurate ERRORLEVEL,
Then I have to preserve that in GOODERROR for use after I get rid of TT2.TXT
Regards
Alan