Exitcodes (errorlevels) of DOS utilities

This document has been very kindly contributed by Matthias Paul as a list of
exitcodes for the different versions of DOS utilities, and should be kept as
reference for the exitcodes. Translation into English by Eric Auer, who has
also shaded some of the commands in light red (missing in FreeDOS) or grey
(specific to another DOS, adding the command to FreeDOS is not planned).

ASSIGN      Novell DOS 7,         0  success / help
            Caldera OpenDOS 7.01  3  aborted by user (e.g. Ctrl-C)
                                  4  syntax error
ATTRIB      MS-DOS 5.0+,          0  success (DR DOS 6.0, too?) for
            Novell DOS 7,            Novell DOS 7 also "file not found"
            Caldera OpenDOS 7.01  1  MS-DOS: file not found / syntax error
                                  3  MS-DOS: aborted (DR DOS 6.0, too?)
                                 31  Novell DOS 7+: invalid option or
                                     aborted by user
APPEND      Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user
BACKUP      MS-DOS 2.1+,          0  success
            DR DOS 6.0,           1  no files to backup
            CCI Multiuser DOS 7.x 2  some files not backed up, access
            Novell DOS 7,            denied or sharing violation
            Caldera OpenDOS 7.01, 3  aborted by user
            PC-DOS 7,             4  aborted because of error
            OS/2 2.0+             5  OS/2 2.0+: reserviert
                                  6  OS/2 2.0+: could not FORMAT disk
COMP        Novell DOS 7,         0  success (even if no target file
            Caldera OpenDOS 7.01     found or file sizes differ!)
                                  3  aborted by user
                                  4  no files or source file not found
                                     or syntax error
            OS/2 2.0+             0  success
                                  1  no files found for comparison
                                  2  some files or directories
                                     could not be processed, file error
                                  3  aborted by user
                                  4  aborted because of error
                                  5  files were different
CHOICE      MS-DOS 6.?+,          x  depends on user keypress
            PC-DOS 7,
            Novell DOS 7,
            Caldera OpenDOS 7.01
CHKDSK      MS-DOS 6.2+,          0  drive found to be okay
            CCI Multiuser DOS 7,  1  only MS DOS: could not check disk
            OS/2 2.0+                because files are open. OS/2:
                                     reserved
                                255  MS DOS / CCI: error found on drive
                                  1  OS/2: reserved
                                  2  OS/2: reserved
                                  3  OS/2: aborted by user
                                  4  OS/2: aborted because of error
                                  5  OS/2: reserved
                                  6  OS/2: CHKDSK could not load module
                                     for this filesystem type
DEFRAG      MS-DOS 6.2+,          0  defragmentation successful
            PC-DOS 7              1  internal error
                                  2  no clusters free (need at least 1)
                                  3  aborted by user
                                  4  general error
                                  5  error when reading a cluster
                                  6  error when writing a cluster
                                  7  FAT error, use scandisk to correct
                                  8  memory error
                                  9  out of memory
DELTREE     MS-DOS 6.2+           0  success
                                  ?  no success
DELWATCH    Novell DOS 7,         0  success
            Caldera OpenDOS 7.01 >27 in combination with /MBL: value
            (DELWATCH 2.1)           is n+27 for /F:n option, default
                                     20+27 for floppy or 200+27 for
                                     harddisk (maximum number of files
                                     in delete-tracking queue).
DISKCOMP    MS-DOS 4.0+,          0  disks are identical
            DR DOS 6.0,           1  disks differ, or for all except
            Novell DOS 7,            OS/2 and MS DOS 4.x also: did not
            Caldera OpenDOS 7.01,    compare (syntax error or invalid
            PC-DOS 7, OS/2 Warp 3    drive specified)
                                  2  aborted by user
                                  3  hardware error, did not compare
                                  4  initialization error, out of
                                     memory, invalid drive or syntax.
DISKCOPY    MS-DOS 4.0+,          0  success (copy done)
            Novell DOS 7,         1  corrected read/write error, for
            Caldera OpenDOS 7.01,    MS-DOS 5.0 also: invalid drive or
            PC-DOS 7,                syntax error
            OS/2 Warp 3           2  aborted by user
                                  3  fatal disk access error: cannot
                                     read source / cannot format target
                                  4  initialization error, out of
                                     memory, invalid drive or syntax
DOSBOOK     Novell DOS 7,         0  success
            Caldera OpenDOS 7.01 31  syntax error
DPMI        Novell DOS 7,         0  state changed
            Caldera OpenDOS 7.01  1  called without parameters and
                                     DPMI not active (else 0 returned)
EAUTIL      OS/2 2.0+             0  success
                                  1  no files found to save
                                  4  aborted because of error
EDIT        Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user
                                  4  syntax error
FASTOPEN    MS-DOS 5.0+           0  success (always returned for
            DR DOS 6.0,              Novell DOS 7 and DR DOS 6.0 )
            Novell DOS 7,         1  syntax error (not for DR DOS 6.0
            Caldera OpenDOS 7.01     and Novell DOS 7: FASTOPEN is
                                     only a dummy command there!)
FC          Novell DOS 7,         0  success or help, no matter if
            Caldera OpenDOS 7.01     files same or different!
                                  1  file(s) not found or syntax error
                                  3  aborted by user
FDISK       Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user
FIND        MS-DOS 5.0+           0  success, for MS DOS 6.2 also:
                                     found string, for Novell DOS and
                                     Caldera OpenDOS 7.01 also: no
                                     files to be processed
                                  1  MS-DOS: success, but no match
                                  2  MS-DOS: syntax error
                                 31  Novell DOS 7: aborted by user,
                                     syntax error or no string given
FORMAT      MS-DOS 4.0+,          0  success
            Novell DOS 7,         3  aborted by user
            Caldera OpenDOS 7.01, 4  fatal error, disk broken or wrong
            PC-DOS 7,                name
            OS/2 2.0+             5  harddisk format confirmation
                                     not given (user selected "no")
                                  6  OS/2 2.0+: FORMAT could not find
                                     the module for that filesystem type
                                  7  OS/2 2.0+: drive not supported by
                                     module for that filesystem type
GRAFTABL    MS-DOS 4.0+,          0  success: loaded with new codepage
            OS/2 2.0+,               (no codepage loaded previously)
            Novell DOS 7,         1  replaced table by new one (loaded
            Caldera OpenDOS 7.01     new codepage into existing TSR)
                                  2  Novell, MS-DOS 4.0+: file error
                                     OS/2 2.0+: no codepage was and
                                     will be loaded
                                  3  syntax error, nothing done
                                  4  wrong DOS version
ISWINDOW    OS/2 Warp 3           0  DOS-Session is in fullscreen mode
                                  1  DOS-Session running in a window
JOIN        MS-DOS 5.0+,          0  success (never for Novell DOS 7
            Novell DOS 7,            and OpenDOS!?)
            Caldera OpenDOS 7.01  1  MS DOS: syntax error
            Novell DOS 7,         1  other: cannot make JOIN directory
            Caldera OpenDOS 7.01  3  other: aborted by user
                                 32  other: displayed the JOIN list
                                 43  other: error
                                255  other: successfully assigned...
KEYB        MS-DOS 4.0+,          0  success
            PC-DOS 7              1  syntax error, charset or key
                                     code invalid
                                  2  wrong or missing keyboard
                                     definition file (keyboard.sys)
                                  3  could not generate keyboard table
                                     in RAM (MS DOS 5 / PC DOS 7?)
                                  4  error accessing CON
                                  5  required codepage not ready
                                  6  table for codepage not found in
                                     resident table in RAM (MS DOS 5 /
                                     PC DOS 7?)
                                  7  invalid DOS version, nothing done
                                     (not for PC-DOS 7?)
LABEL       MS-DOS 5.0+           0  success
            Novell DOS 7,         1  MS DOS: invalid or non-existing
            Caldera OpenDOS 7.01  2  not MS DOS: aborted by user
                                  4  not MS DOS: syntax error or
                                     invalid or non-existing drive
MEMMAX      Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user
MODE        MS-DOS 5.0+           0  success
                                  1  syntax error
MORE        Novell DOS 7,         0  help screen displayed
            Caldera OpenDOS 7.01  3  aborted by user during (possibly
                                     redirected) input processing
                                255  success, or aborted by user during
                                     (possibly redirected) output
                                     processing / paginated display
MOVE        MS-DOS 6.2+           0  success
                                  1  failure
NLSFUNC     Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user
OPENS       CCI Multiuser DOS 7.x 0  no files open
                                  3  there are files open on the system
RECOVER     Novell DOS 7,         0  success
            Caldera OpenDOS 7.01, 1  OS/2 Warp 3: no files to process
            OS/2 2.0+             2  OS/2 Warp 3: some files could not
                                     be processed due to access error
                                     sharing violation
                                  3  aborted by user
                                  4  OS/2 2.0+: aborted because of
                                     error
                                  5  OS/2 2.0+: reading or writing
                                     failed in FAT area
                                  6  OS/2 2.0+: the module for this
                                     particular filesystem could not
                                     be run
REPLACE     MS-DOS 4.0+,          0  success
            PC-DOS 7,             1  OS/2 2.0+: no files to replace
            OS/2 2.0+             2  (source) file not found
                                     OS/2 2.0+: some directories or
                                     files could not be processed,
                                     file error
                                  3  path not found (PC-DOS 7 also:
                                     source file not found)
                                  4  OS/2 2.0+: aborted because of
                                     errors
                                  5  access to source file denied
                                     OS/2 Warp 3: use /R to override
                                  8  out of memory (not OS/2 2.x?)
                                 11  syntax error (not OS/2 2.x?)
                                 15  drive invalid (not for MS DOS
                                     5.0 and OS/2 2.x?)
RESTORE     MS-DOS 4.0+,          0  success
            DR DOS 6.0,           1  no files to restore
            CCI Multiuser DOS 7.x 2  some files could not be restored
            Novell DOS 7,            due to access / sharing violations
            Caldera OpenDOS 7.01,    (not PC-DOS 7?)
            PC-DOS 7,             3  aborted by user
            OS/2 2.0+             4  aborted after other error, source
                                     has no backup data, syntax error
SCANDISK    MS-DOS 6.2+           0  success
                                  1  syntax error
                                  2  out of memory, internal error
                                  3  aborted by user
                                  4  filesystem okay but no full
                                     surface scan for all drives done
                                     (or aborted). Not if surface scan
                                     was suppressed completely.
                                254  errors found but corrected
                                255  errors found but not all corrected
SETVER      MS-DOS 4.0+,          0  success
            PC-DOS 7,             1  syntax error (Novell / PC DOS 7:
            (Novell DOS 7,           invalid DOS version specified)
            Caldera OpenDOS 7.01) 2  file name invalid
                                  3  out of memory, cannot load
                                  4  invalid version number format
                                  5  version table entry not found
                                  6  SETVER.EXE not found for patching
                                  7  invalid drive
                                  8  too many command line switches
                                  9  command line switch missing
                                 10  error reading SETVER.EXE
                                 11  SETVER.EXE damaged or unuasable
                                 12  SETVER.EXE not found (or, MS DOS
                                     6.2 / PC DOS 7: SETVER.EXE does
                                     not support version table?)
                                 13  out of space in version table
                                 14  error writing SETVER.EXE
SORT        Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  1  file too big (more than 64k?)
            MS-DOS, PC-DOS           (not happening with Novell / Open
                                     DOS, can handle bigger files!?)
                                  2  Novell / Caldera: aborted by user
                                  4  Novell / Caldera: syntax error
SUBST       MS-DOS 5.0+,          0  success
            Novell DOS 7,         1  syntax error (Novell: not enough
            Caldera OpenDOS 7.01     arguments)
                                 3+  Novell: length of the TRUENAME of
                                     a changed SUBST drive (3..67)
                                     Maybe this errorlevel is returned
                                     inadvertedly, but it is useful.
SYS         Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  3  aborted by user / cannot write
                                     boot sector
                                  4  syntax error
TOUCH       Novell DOS 7,         0  ok / help
            Caldera OpenDOS 7.01 31  no file name given, syntax error,
                                     TOUCH failed for some files
TREE        Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  1  syntax error, drive access error
                                  3  aborted by user
                                  4  read error (no disk in drive)
UNDELETE    Novell DOS 7,         0  success (no function?)
            Caldera OpenDOS 7.01  2  ???
                                 31  general error (errorcode xx),
                                     e.g. errorcode 3 for invalid
                                     time format in /T: argument
UNFORMAT    Novell DOS 7,         0  success
            Caldera OpenDOS 7.01  1  invalid drive
                                  3  aborted by user
                                  4  cannot read drive (no floppy)
UNPACK      OS/2 2.0+             0  success
                                  1  no files found for unpacking
                                  2  some files or directories could
                                     not be processed, file error
                                  3  aborted by user
                                  4  aborted because of error
XCOPY       MS-DOS 4.0+,          0  success
            Novell DOS 7,         1  no files to copy
            Caldera OpenDOS 7.01, 2  aborted by user (not for PC DOS?)
            PC-DOS 7,                OS/2 2.0: some files or directories
            OS/2 2.0+                could not be processed, file error
                                  3  OS/2 2.0, PC-DOS 7: aborted by user
                                  4  initialization error, out of memory,
                                     invalid options, disk full, file or
                                     path not found.
                                  5  INT24 when reading/writing data