Batch File Error Handling

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.
3 answers Last reply
More about batch file error handling
  1. 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
  2. ksiemb said:


    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.
  3. Set the variables in xp, then use them in your script.

    http://support.microsoft.com/kb/310519
Ask a new question

Read More

Macros Windows XP