1.

Solve : Log File?

Answer»

Hey guys,

I have a simple one here, i just can't figure it out CORRECTLY. I have a huge BAT file that copies all the contents from one folder to the "all users" desktop folder on ALL our computers that are on our "staff" network. I just want to create a small log file that simply states the start TIME that the BAT was run and the end time of the BAT. That's it. Well sort of. I want to have it create a log file with the date in the title. (i.e. log_07092009.txt). Then is the file was run again, on the same day,  it would add a line in the created text file.

So i have this is the begining:
Code: [Select]ECHO Push to all STAFF computers started at %date% %time% by %username%>>"%~dp0\Log Files\%DATE%_backuplog.txt"and this at the end:
Code: [Select]echo Push to all STAFF computers completed at %date% %time% by %username%>>"%~dp0\Log Files\%DATE%_backuplog.txt"
echo ---------------------------------------->>"%~dp0\Log Files\%DATE%_backuplog.txt"
but i get this and can not figure out why:
Code: [Select]The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Press any key to continue . . .
Thank you guys for the help!%~dp0 AFAIK Not valid outside a For loop, also requires double % in a batch script as in %%~dp0

okay, i managed to get this going. Below is a sample of how i was able to get the date in the file name.

Code: [Select]FOR %%A IN (%Date:/=%) DO SET Today=%%A

echo ******************************************************* >>"Log Files\Log__%TODAY%.txt"
echo Started Push to ALL STAFF Desktops on %DATE% %TIME% >>"Log Files\Log__%TODAY%.txt"
echo ******************************************************* >>"Log Files\Log__%TODAY%.txt"
echo. >>"Log Files\Log__%TODAY%.txt"

USING this i now have the following file name scheme.

Quote

Log__07092009.txt


Discussion

No Comment Found