Need to execute interactive job generating log file having year, month, day and time.
myscript.bat > LOG-YYYYMMDDHHMM.txt
Since I will have the script executing several times per day, the "time" part of the log file is critical, to be able to tell what time during the day the job executed.
How can that be done easily? I looked at some of the suggested examples, but none were close enough to the above.
I don't want PowerShell, just basic Windows command-line stuff.
Okay, here is what I do - not perfect, but it works:
set hr=%hr: =0%
cscript.exe c:\scripts\agepwd.vbs > c:\scripts\agepwd-LOG-%date:~10%%date:~4,2%%date:~7,2%%hr%%time:~3,2%.txt
Above gives output file name like: agepwd-LOG-201310140733.txt (this would be a script that ran Oct 14, 2013 at 07:33 am.
Hope this was helpful. Please remember to Mark as Answer (and VOTE!) - It's okay to mark Multiple answers, if more than one answer helped solve your issue. Thanks!
Thank you - I just tested your logic, and it works great for me. This is just what I needed.
Microsoft is conducting an online survey to understand your opinion of the Technet Web site. If you choose to participate, the online survey will be presented to you when you leave the Technet Web site.
Would you like to participate?