• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

send result to a txt based log file

Dear all expertise,

Right now I want to create a .bat file and execute it while export the result to a txt file, how can I do the export of result to a txt file ?

  • 3
2 Solutions
Try to launch your Batch fril fomr command line, add this syntax:

Mybatfile.bat 2>c:\temp\ERROR.TXT >c:\TEMP\LOG.txt
oh my god, I typed too fast !
I meant "Try to launch your Batch file from a command line" of course.

This syntax will redirect error canal(2) in error.txt file and output canal (1) in Log.txt file.
As an additon to Gerald26's postings, it is possible to redirect any errors to the same file as the main output (stdErr and stdOut).

mybatfile.bat > c:\temp\log.txt 2>&1

The 2>&1 tells it to put the errors into the first log file.
And finally you can use

Mybatfile.bat >> C:\temp\log.txt 2>&1 to add new content to old log file each time you start your batch program without erasing previous output.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now