Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am scheduling a DOS batch script to run through Task Scheduler. Is there a way to configure the task/job to write all output (producing output using ECHO commands) to a log file? Can logging be configured within Task Scheduler (appears v1.0 is installed).

share|improve this question
up vote 6 down vote accepted

You could either edit the script to output all to a file instead of the screen or you could just create a batch file to run the batch file and schedule the other batch file... (sorry, sounds confusing, I know).

Basically, assuming the batch file you run is called "myscript.cmd" create a batch file called "myscript-logging.cmd". In that batch file put one command as follows:

myscript >c:\myscript.%date:~-4%%date:~4,2%%date:~7,2%.%time::=%.log 2>&1

The above should create a log file in the root of the C: drive with a name based on the date and time it was executed (so it never overwrites it and you have a log for each time the script is run). The example above, if the script were run at 10pm on June 22, 2010, should end up with a file name that looks like this:

myscript.20100622.220000.00.log format of: myscript.YYYYMMDD.HHMMSS.hundredths of a second.log

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .