How to re-direct erros in cmd?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

When I run a batchfile in Windows and have it redirect it's output like so:

blah.bat > verify.txt

It sends error messages to the console, and not to verify.txt. How can I
get the error messages to go to verify.txt as well?

Robert
 
supersonic_oasis said:
Hi all,

When I run a batchfile in Windows and have it redirect it's output like
so:

blah.bat > verify.txt

It sends error messages to the console, and not to verify.txt. How can I
get the error messages to go to verify.txt as well?

Robert

You have to capture "stderr" (C language). All programs have stdin, stdout
and stderr. I'm pretty sure it works the same way as it does in UNIX/Linux
flavors of OS's - your command would be something like this:

blah.bat > verify.txt 2>&1

-or- if you wanted a log file and error file:

blah.bat > blah.log 2> blah.err

YMMV depending on the commands in the bat file.
 
Hi all,

When I run a batchfile in Windows and have it redirect it's output like so:

blah.bat > verify.txt

It sends error messages to the console, and not to verify.txt. How can I
get the error messages to go to verify.txt as well?

Duplicating handles
The & redirection operator duplicates output or input from one specified
handle to another specified handle. For example, to send dir output to
File.txt and send the error output to File.txt, type:

dir>c:\file.txt 2>&1

Quoted from:
mk:@MSITStore:%windir%\Help\ntcmds.chm::/redirection.htm

More:
Start "" %windir%\Help\ntcmds.chm
 
Back
Top