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).

link|improve this question

feedback

1 Answer

up vote 1 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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.