Batch File Error Handling

datagopher

Distinguished
Jun 18, 2011
6
0
18,510
I have several batch files that are ran from Scheduled Tasks. They perform functions such as copying files and running macros. I need a way to determine if a job did not complete and then write that error to the text file. I do not need to necessarily need to know the exact error code but that would be nice, I just need to know if a job did not run successfully.

Any assistance would be appreciated.
 

errorlevel check ? http://www.robvanderwoude.com/errorlevel.php
 

datagopher

Distinguished
Jun 18, 2011
6
0
18,510


Thanks for the answer. That will work for some of what I'm doing but not all. I found out that for some of it, I'm going to have to do at the program level.

Another question for you, which I'm sure is easy. How do I assign directory paths and file names to a variable such as below.

[cpp]
myvar=C:\MyFolder\myfile.txt
myvar2=C:\MyFolder\Backup\myfile.txt

copy %myvar% %myvar2% /v
[/cpp]

I've tried this, which I thought would be correct but does not work. Could you tell me what I'm doing wrong? Thanks.