MS-DOS 6.22 PATH Command Resolution

In MS-DOS 6.22, the PATH command sets an environment variable containing a list of directories that the operating system searches when attempting to execute a command. When a user or batch file invokes an executable that does not reside in the active directory, MS-DOS uses this designated search path to locate and launch the file automatically, removing the need to type the full file path.

The MS-DOS 6.22 Command Search Order

When a command is entered into COMMAND.COM, MS-DOS 6.22 follows a rigid sequence to resolve and run it:

  1. Internal Commands: MS-DOS first checks whether the entered string matches an internal command built directly into COMMAND.COM (such as DIR, COPY, or DEL). If a match exists, it executes immediately.
  2. Current Directory: If the input is not an internal command, DOS searches the current working directory for an executable file matching the command name. It checks file extensions in a specific order:
    • .COM
    • .EXE
    • .BAT
  3. The PATH Directory List: If no matching file exists in the current directory, the operating system turns to the directories defined by the PATH command.

How the PATH Command Operates

The PATH command creates or updates the PATH environment variable, which stores directory paths separated by semicolons. A typical entry looks like:

PATH C:\DOS;C:\UTIL;C:\BATCH

When evaluating the path, MS-DOS scans each folder sequentially from left to right:

  • MS-DOS checks the first directory (C:\DOS) for a matching .COM, .EXE, or .BAT file, in that order.
  • If no match is found, it proceeds to the next directory (C:\UTIL) and checks the file extension hierarchy again.
  • The search stops immediately upon finding the first valid match, and the program executes. Any duplicate executables residing in directories further down the list are ignored.

If the operating system evaluates every directory defined in the PATH without locating a matching executable, it halts the process and returns the standard error message: Bad command or file name.

Usage and Management

In MS-DOS 6.22, the PATH statement is typically executed during startup inside the AUTOEXEC.BAT file to guarantee that system tools located in C:\DOS are accessible from any drive or directory.

Typing PATH without parameters displays the currently active search path, while typing PATH ; clears all directories from the variable, restricting execution exclusively to internal commands and files in the active directory.