The Role of COMMAND.COM in MS-DOS 6.22

In MS-DOS 6.22, COMMAND.COM serves as the default command interpreter and user interface, bridging the gap between the user, the operating system kernel, and computer hardware. It is responsible for presenting the command prompt, reading user inputs, directly executing built-in commands, processing batch scripts, and loading external applications into memory. Without COMMAND.COM—or an alternative shell specified in the system configuration—users cannot interact with the operating system once MS-DOS completes its boot sequence.

Primary Functions of COMMAND.COM

1. Providing the User Interface

COMMAND.COM generates the interactive command-line interface, typically displayed as the C:\> prompt. It monitors keyboard input, handles text editing shortcuts (such as the F3 key to repeat the last command), and parses the text typed by the user to determine the appropriate action.

2. Executing Internal Commands

To ensure fast performance and save disk access, COMMAND.COM contains built-in routines for essential file and system management operations known as internal commands. These do not require separate executable files on disk. Common internal commands include:

  • File Management: DIR, COPY, DEL, REN, TYPE
  • Directory Navigation: CD (CHDIR), MD (MKDIR), RD (RMDIR)
  • System Control: CLS, DATE, TIME, VER, PATH, PROMPT

3. Loading and Launching External Programs

When a user enters a command that is not built into the interpreter, COMMAND.COM searches the current directory and the directories defined in the system PATH for an executable file ending in .COM, .EXE, or .BAT. It makes the appropriate system calls to the DOS kernel (MSDOS.SYS) to allocate memory, load the program into RAM, pass any entered parameters, and transfer execution control to that program. Once the external application exits, COMMAND.COM resumes control.

4. Processing Batch Files

COMMAND.COM acts as a script interpreter for .BAT files, including the startup script AUTOEXEC.BAT. It executes instructions line by line and manages basic scripting logic, including environment variables (%VAR%), loops (FOR), conditional statements (IF), and flow controls (GOTO).

The Resident and Transient Architecture

To optimize the limited 640 KB conventional memory typical of the MS-DOS era, COMMAND.COM is split into two distinct parts:

  • The Resident Portion: Stored in low conventional memory just above the DOS kernel and device drivers. It contains the core interrupt handlers, routines to reload the rest of the shell, and the logic required to handle critical errors (such as "Abort, Retry, Fail?"). It remains in memory at all times.
  • The Transient Portion: Loaded into the highest addresses of conventional memory. This section contains the command prompt display routines, internal command code, and the batch file parser.

When a large application requires more memory than is currently free, the application is permitted to overwrite the transient portion of COMMAND.COM. When the application terminates, the resident portion performs a checksum validation. If the transient portion was overwritten, the resident portion automatically reloads it from disk (using the file path defined in the COSPEC environment variable) before returning the user to the prompt.