How to re-direct erros in cmd?  
Author Message
Sharon





PostPosted: Sat Apr 21 18:52:46 CDT 2007 Top

Windows XP Security >> How to re-direct erros in cmd? 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

Windows XP1218  
 
 
Admiral





PostPosted: Sat Apr 21 18:52:46 CDT 2007 Top

Windows XP Security >> How to re-direct erros in cmd? "supersonic_oasis" <EMail@HideDomain.com> wrote in
message news:EMail@HideDomain.com...
> 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.

--
---
Star Fleet Admiral Q @ your service!
"Google is your Friend"
http://www.google.com


 
 
Michael





PostPosted: Sun Apr 22 08:02:44 CDT 2007 Top

Windows XP Security >> How to re-direct erros in cmd? On Sat, 21 Apr 2007 13:50:01 -0700, supersonic_oasis wrote in
microsoft.public.windowsxp.security_admin:

>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

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"