How MS-DOS 6.22 Handles Invalid File Extensions

In MS-DOS 6.22, command execution relies entirely on the command processor (COMMAND.COM) to parse input strings, resolve file paths, and validate executable file types. When a user or script attempts to execute a file targeting an unrecognized or non-existent executable file extension, MS-DOS 6.22 enforces strict parsing rules that restrict execution solely to .COM, .EXE, and .BAT files. Instead of falling back to default handlers or inspecting file headers, the shell immediately abandons the execution pipeline and raises a standard error message.

Command Line Parsing and Tokenization

When a command is submitted at the command prompt, COMMAND.COM reads the string from standard input into an internal command buffer. The shell first strips leading whitespace and tokenizes the input to extract the command name from any accompanying parameters or switches.

Before searching the filesystem, COMMAND.COM checks the base name against its internal command table (such as DIR, COPY, DEL, or VER). If the command matches an internal command, it executes internally regardless of any extraneous extension provided. If no internal match exists, the command processor initiates an external file lookup.

Extension Resolution and Validation

MS-DOS 6.22 only supports three executable formats:

  1. .COM: Flat binary memory images limited to a single 64 KB segment.
  2. .EXE: Relocatable executables containing the standard DOS "MZ" header.
  3. .BAT: Plain text batch files parsed and interpreted line-by-line by COMMAND.COM.

If an execution call includes an explicit extension—such as PROGRAM.DAT, RUN.SYS, or FILE.XYZ—COMMAND.COM parses the extension from the filename. Because MS-DOS 6.22 lacks a native file association engine (such as ASSOC or FTYPE found in later Windows NT shells), the command interpreter immediately validates the requested extension against its hardcoded list of allowed executable extensions.

If the extension specified by the user is not .COM, .EXE, or .BAT, COMMAND.COM does not attempt to execute the file. It will not load the file into memory, check for binary signatures, or invoke the MS-DOS execution interrupt (INT 21h, Function 4Bh - EXEC).

Path Traversal Behavior

When an invalid or non-executable extension is explicitly declared:

  • The shell does not strip the extension to look for an alternative valid extension (such as converting TEST.TXT into TEST.EXE).
  • The shell traverses the current working directory, followed by the directories defined in the PATH environment variable, specifically looking for the exact string provided.
  • Even if a file with that exact name and invalid extension exists on disk (for example, README.TXT), COMMAND.COM identifies that the file lacks a recognized executable format and discards it as an execution target.

Error Dispatching

Once COMMAND.COM exhausts its search without finding a valid executable matching the input parameters, it terminates the execution routine. It outputs the standard error message to the screen:

Bad command or file name

Control returns immediately to the command prompt loop, setting the internal exit state without modifying system memory or invoking low-level DOS kernel loaders.