troubleshooting Question

Issue Running a Batch file and piping to a text Log file

Avatar of lasthope
lasthope asked on
Microsoft DOSWindows OSMicrosoft Server OS
8 Comments1 Solution1006 ViewsLast Modified:
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!!
 
ASKER CERTIFIED SOLUTION
Steve Knight
IT Consultancy

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros