Outputting batch file error output

Hi all,

A novice here.

I have a very simple batch file and I would like to write only its stderr output to a txt file. The batch file contains only one line

mxmlc filename

I know that I don't need a batch file for this but I don't have any control over that part of the program.

so I know can do the following

mxmlc filename 2>>error.log

However, the file error.log will get created even if there was no error generated from the script.

I know I can use errorlevel but then I won't know what the error was. Somehow I need to capture the output from the command and then check for errorlevel and if error level is 1 then I can output the error to a log file, otherwise I don't need to write anything to error.log

thanks
1 answer Last reply
More about outputting batch file error output
  1. Take a look here: http://www.robvanderwoude.com/errorlevel.php

    Try using if not %errorlevel%==0 echo %errorlevel% > error.log
Ask a new question

Read More

Command Prompt Windows XP