Re: logging batch files
From: Matthias Tacke (Matthias_at_Tacke.de)
Date: 04/01/04
- Next message: Todd hobdey: "Demote Win2K DC via command line"
- Previous message: DS: "Batch blitz"
- In reply to: Rob P: "Re: logging batch files"
- Next in thread: guard: "Re: logging batch files"
- Reply: guard: "Re: logging batch files"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Apr 2004 19:22:21 +0200
"Rob P" wrote:
>"Joe Vaughan" <jvaughan@locktonrisk.com> wrote in message
>news:171cb01c417ef$edeea880$a101280a@phx.gbl...
>> Is there a way to log everything from the beginning of a
>> batch file to the end while it processes? I want to
>> capture the progress of batch files in a log. Any idea
>> how?
>Jerold replied to my similar post several days ago with the following
>information. It was exactly what I was looking for.
>
>@ECHO ON
>call :Logit>>batch.log 2>&1
>exit /b 0
>:Logit
>COMMAND 1
>COMMAND 2
>ETC
>
That is a really nice trick from Jerold. This extends it a bit:
@echo off
if /I "%1" NEQ "/log" goto :LogIt
set LogFil=%~dpn0.log
shift
echo on
call :LogIt %1 %2 %3 %4 %5 %6 %7 %8 %9 >%LogFil% 2>&1
goto :eof
:LogIt
::your normal batch code
Drawback of this prependable fragment is, it garbles the %0 value and
the /log argument which enables logging has to be the first.
If the count of needed arguments is greater than 9 it won't work either.
The log file is created in the folder where the batch resides.
The log file name can easily be extended with %date%.
Otherwise prepend your batch with this snippet and you have a logging
option.
-- Greetings Matthias________________________________________ For help on nt commands enter in a cmd window: W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
- Next message: Todd hobdey: "Demote Win2K DC via command line"
- Previous message: DS: "Batch blitz"
- In reply to: Rob P: "Re: logging batch files"
- Next in thread: guard: "Re: logging batch files"
- Reply: guard: "Re: logging batch files"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|