Logging Batch File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hartland1234
Posts: 3
Joined: 05 Aug 2011 04:03

Logging Batch File

#1 Post by hartland1234 » 15 Aug 2011 03:09

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Logging Batch File

#2 Post by aGerman » 17 Aug 2011 13:34

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

Ocalabob
Posts: 79
Joined: 24 Dec 2010 12:16
Location: Micanopy Florida

Re: Logging Batch File

#3 Post by Ocalabob » 18 Aug 2011 20:05

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!

Post Reply