Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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