Sign in with
Sign up | Sign in
Your question

Batch File Error Handling

Last response: in Windows XP
Share
August 30, 2011 12:15:09 PM

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.
August 30, 2011 2:14:19 PM

datagopher said:
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
m
0
l
August 31, 2011 12:57:01 PM

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


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.

  1. myvar=C:\MyFolder\myfile.txt
  2. myvar2=C:\MyFolder\Backup\myfile.txt
  3.  
  4. copy %myvar% %myvar2% /v


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

m
0
l
!