Exit Codes or Errorlevels Set by MS-DOS Commands

Article translations Article translations
Article ID: 81819 - View products that this article applies to.
This article was previously published under Q81819
Expand all | Collapse all

SUMMARY

Several MS-DOS commands set a value detectable using the IF ERRORLEVEL command. These values are called "errorlevels," "return codes," or "exit codes." These commands are:

  • BACKUP
  • CHKDSK
  • CHOICE
  • DEFRAG (codes defined in versions 6.x)
  • DELTREE
  • DISKCOMP
  • DISKCOPY
  • DOSKEY
  • FIND
  • FORMAT
  • GRAFTABL (codes defined in versions 3.3x and later)
  • KEYB (codes defined in versions 4.x and later)
  • MOVE
  • MSAV (codes defined in versions 6.0 and later)
  • REPLACE
  • RESTORE
  • SCANDISK (codes defined in versions 6.2 and later)
  • SETVER (codes defined in versions 5.x and later)
  • XCOPY

MORE INFORMATION

Any program in the MS-DOS environment can set an exit value that can be detected with IF ERRORLEVEL. Any MS-DOS command can return a value, but only the above commands have exit codes defined in the MS-DOS specifications. Return values from other commands should not be relied upon, as they may be different for different versions and dialects of MS-DOS.

None of the internal MS-DOS commands have defined return codes. An external command is a separate MS-DOS program; internal commands are contained within COMMAND.COM and are always available for use when the MS-DOS prompt is active.

You can determine if a command is internal or external by checking your MS-DOS documentation. In MS-DOS 5.0 and 5.0a, commands are marked as internal or external in the chart that accompanies each command in Chapter 14 of the "Microsoft MS-DOS User's Guide and Reference" manual. Earlier versions of the manual include a boxed E or I symbol on the upper outside corner of the page to denote external or internal.

Customers have suggested that exit codes be defined for all appropriate MS-DOS commands (both internal and external). This feature is under review and will be considered for inclusion in a future release.

Properties

Article ID: 81819 - Last Review: November 16, 2006 - Revision: 2.1
APPLIES TO
  • Microsoft MS-DOS 3.1
  • Microsoft MS-DOS 3.2 Standard Edition
  • Microsoft MS-DOS 3.21 Standard Edition
  • Microsoft MS-DOS 3.3 Standard Edition
  • Microsoft MS-DOS 3.3a
  • Microsoft MS-DOS 4.0 Standard Edition
  • Microsoft MS-DOS 4.01 Standard Edition
  • Microsoft MS-DOS 5.0 Standard Edition
  • Microsoft MS-DOS 5.0a
  • Microsoft MS-DOS 6.0 Standard Edition
  • Microsoft MS-DOS 6.22 Standard Edition
Keywords: 
KB81819
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com