• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Checking for Command Errors

Checking for Command Errors

Good batch files (especially those that other people will be using) always assume that if anything bad can happen, it will. So far you’ve seen how IF can handle missing parameters and file problems, but there’s much more that can go haywire. For example, what if a batch file tries to use XCOPY, but there’s not enough memory? Or what if the user presses Ctrl+C during a format or copy? It might seem impossible to check for these kinds of errors, but it is not only possible, it’s really quite easy.

When certain commands finish, they always file a report on the progress of the operation. This report, or exit code, is a number that tells DOS how things went. For example, Table C.1 lists the exit codes used by the XCOPY command.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint