Exit Codes or Errorlevels Set by MS-DOS Commands (81819)



The information in this article applies to:
    Microsoft MS-DOS operating system 3.1
    Microsoft MS-DOS operating system 3.2
    Microsoft MS-DOS operating system 3.21
    Microsoft MS-DOS operating system 3.3
    Microsoft MS-DOS operating system 3.3a
    Microsoft MS-DOS operating system 4.0
    Microsoft MS-DOS operating system 4.01
    Microsoft MS-DOS operating system 5.0
    Microsoft MS-DOS operating system 5.0a
    Microsoft MS-DOS operating system 6.0
    Microsoft MS-DOS operating system 6.22

This article was previously published under Q81819

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.

Modification Type: Major Last Reviewed: 5/12/2003
Keywords: KB81819