Internal vs External Commands in MS-DOS 6.22

MS-DOS 6.22 distinguishes between internal commands and external utilities based on where the executable instructions are stored and how the command processor parses user input. Internal commands are permanently built directly into the primary shell file, COMMAND.COM, and reside in memory for immediate access. External utilities, conversely, exist as individual executable files on a disk drive and must be located, read, and loaded into random access memory (RAM) each time they are invoked.

The Role of COMMAND.COM

When MS-DOS 6.22 boots, it loads COMMAND.COM into memory to serve as the default command interpreter. COMMAND.COM provides the interactive prompt (such as C:\>) and contains a hardcoded lookup table listing all supported internal commands. When a user types a command and presses Enter, COMMAND.COM parses the string to identify the command name and begins its identification process.

Identifying Internal Commands

Internal commands are essential, lightweight operations required for routine file and environment management, such as DIR, COPY, DEL, CD, MD, and TYPE.

Because these instructions are embedded within COMMAND.COM's binary code, they require no disk access to execute once the shell is in memory. When text is entered at the prompt:

  1. COMMAND.COM parses the first token of the input string.
  2. It compares this token against its internal table of command names.
  3. If an exact match is found, the interpreter jumps directly to the corresponding memory address within its own code space to execute the instruction immediately.

Identifying External Utilities

External utilities are specialized, larger, or less frequently used programs that are distributed as separate files, such as FORMAT.COM, CHKDSK.EXE, XCOPY.EXE, MEM.EXE, or custom .BAT batch files.

If the entered command does not match any entry in the internal lookup table, COMMAND.COM assumes the command refers to an external file and initiates a disk search:

  1. Current Directory Search: The interpreter first inspects the active working directory for an executable file matching the command name. It checks extensions in a fixed order of precedence: .COM, then .EXE, and finally .BAT.
  2. PATH Environment Variable Search: If no matching file is found in the current directory, COMMAND.COM evaluates the directories defined in the PATH environment variable, searching them sequentially from left to right using the same .COM, .EXE, .BAT precedence.
  3. Execution or Error: If an executable file is found, MS-DOS allocates memory, loads the file from the disk into RAM, transfers execution control to the program, and unloads it upon completion. If the search exhausts the PATH without locating a match, it displays the standard error message: Bad command or file name.

Precedence and Execution Order

Because of this evaluation structure, MS-DOS 6.22 always prioritizes internal commands over external programs with identical names. If a user creates a script or executable named DIR.BAT, entering DIR will invoke the internal directory listing command instead of the script. To bypass this, the user must explicitly provide the file extension or the full path (e.g., DIR.BAT or .\DIR.EXE), signaling to COMMAND.COM to skip the internal table and query the file system directly.