# Get logs after batch file runs



## rajbps (Oct 4, 2011)

Hiya,

I have the following batch file that runs on a daily basis and I would like it to write a daily log of how it ran.

Here is the file :

Set FDate=%Date:~-10,10%
Set Fdate=%FDate:/=-%
MD "D:\Fax\Archive\%FDate%"
xcopy "D:\Fax\*.TIF" "D:\Fax\Archive\%FDate%"
DEL "D:\Fax\*.TIF" 



Could anyone assist me with it pls?

Cheers,

raj


----------



## Squashman (Apr 4, 2003)

http://www.robvanderwoude.com/redirection.php


----------



## rajbps (Oct 4, 2011)

Could you provide an example pls.

Cheers,

raj


----------



## rajbps (Oct 4, 2011)

Set FDate=%Date:~-10,10%
Set Fdate=%FDate:/=-%
cd 
c:\try.bat >>c:\%FDate%log.txt
pause
goto :blat)
:blat
START /WAIT C:\blat262\full\blat.exe - -s "Test mail from access" -to [email protected] -f [email protected] -server 192.168.0.24 -body "TEST" -attach "c:\%FDate%log.txt" 
pause
del "c:\%FDate%log.txt"
pause

Ok so I created a second batch file and manage to get the log.

Now I am trying to get it emailed to me but it the file dies after the first pause and does not even pause.

What am i doing wrong pls?


----------



## Squashman (Apr 4, 2003)

It should pause on Line 5 of your code.

I am not sure why you have a right parenthesis after your Goto statement on Line 6. You don't even need the Goto Statement. Your not jumping over any code.


----------



## rajbps (Oct 4, 2011)

Set FDate=%Date:~-10,10%
Set Fdate=%FDate:/=-%
cd
c:\try.bat >>c:\%FDate%log.txt
pause
START /WAIT C:\blat262\full\blat.exe - -s "Test mail from access" -to [email protected] -f [email protected] -server 192.168.0.24 -body "TEST" -attach "c:\%FDate%log.txt"
pause
del "c:\%FDate%log.txt"
pause

still no joy and still does not stop at first line :-(


----------



## Squashman (Apr 4, 2003)

Of course it is not going to stop on the first line. The set command will not stop your batch file from executing.

Please use Bulletin Board Code tags when posting your code from now. Makes it easier to read for most people who are going to help you.

```
Set FDate=%Date:~-10,10%
Set Fdate=%FDate:/=-%
cd
c:\try.bat >>c:\%FDate%log.txt
pause
START /WAIT C:\blat262\full\blat.exe - -s "Test mail from access" -to [email protected] -f [email protected] -server 192.168.0.24 -body "TEST" -attach "c:\%FDate%log.txt"
pause
del "c:\%FDate%log.txt"
pause
```
I can't see what is going on with your batch file. Telling me it is not working doesn't give me much to work with. You have to describe in better detail what is going on with your batch file. What is it outputting and if there are any error messages.

The best way to debug a batch file is to execute it from the command prompt and make sure your batch file doesn't have ECHO turned off.

So open up a cmd prompt.
Execute your batch file from within the cmd window.
Copy everything it outputs and paste that output here on the forums.


----------

