Issue Running a Batch file and piping to a text Log file
Posted on 2011-03-09
I want to run a scheduled task that executes a .bat file. The .bat file works fine. The problem I'm having is naming the .txt log file I create when running this .bat.
I hope this is clear - Here is what's happening:
From Command Prompt I run my batch file and pipe (>) to a .txt log file as follows:
batch.bat > logfile-%date:~4,2%-%date:~7,2%-%date:~10,4%_@_%time:~0,2%h%time:~3,2%m%time:~6,2%s.txt
This produces my logfile named appropriately with date and time as "logfile-03-10-2011_@_11h10m17s.txt" - this is perfect
But if I run this batch file as a Scheduled Task the log file is created as "logfile-03-10-2011_@_" No file extension and without the time stamp. Not acceptable.
I would really like to have the Time Stamp (and .txt extension) in the logfile name - the date wouldn't have to be in the exact time format.
How can this be accomplished?
Thanks in advance!!