Page 1 of 1

Logging Batch File

Posted: 15 Aug 2011 03:09
by hartland1234
Hello,
I have read a bit but am still confused on the topic. My understanding is very basic, but I have wrote quite a few batch files to carry out a lot of different tasks and I was wondering if there is a way of getting the batch file to log this everytime it runs?

Thanks

Re: Logging Batch File

Posted: 17 Aug 2011 13:34
by aGerman
You could write a log file by ECHO redirection.

Code: Select all

@echo off &setlocal
>test.log echo Hello
>>test.log echo World!

... where > creates/overwrites a file and >> appends to an existing file.

Regards
aGerman

Re: Logging Batch File

Posted: 18 Aug 2011 20:05
by Ocalabob
If you just want to log each time a batch file is run then you might try something like this:
echo File %0 run on %date% at %time%>>my_log.txt

Post back and re-phrase your question if your problem is not answered.

Best wishes!