How MS-DOS 6.22 Resolves Path in AUTOEXEC.BAT
In MS-DOS 6.22, the AUTOEXEC.BAT file uses the
PATH command to define where the operating system searches
for executable files when a command is entered without a specific
directory. During startup, the command processor
(COMMAND.COM) reads this definition, stores it in memory as
an environment variable, and references it sequentially whenever an
unknown command is invoked. Understanding this resolution process
requires examining how the path environment is initialized, the strict
hierarchy MS-DOS applies when evaluating commands, and the
file-extension precedence it follows.
Path Initialization in AUTOEXEC.BAT
During the boot process, after CONFIG.SYS runs,
COMMAND.COM automatically executes
C:\AUTOEXEC.BAT. Within this batch file, the
PATH statement specifies a list of directories separated by
semicolons:
PATH C:\DOS;C:\WINDOWS;C:\UTILSAlternatively, this can be written using
SET PATH=....
When parsed, COMMAND.COM allocates memory in the master
environment block to store this string under the PATH
variable. In MS-DOS 6.22, standard command lines—including
PATH definitions—are limited to 127 characters unless
expanded via the SHELL command with the /E:
switch in CONFIG.SYS.
MS-DOS does not validate whether these directories exist when the
PATH variable is initialized; it merely stores the string
as raw text.
The Search and Resolution Hierarchy
When a user or a batch script enters a command (e.g.,
EDIT), MS-DOS 6.22 does not immediately scan the
directories listed in the PATH. Instead, it resolves the
command using a fixed hierarchy:
- Internal Commands: MS-DOS first checks if the
string matches an internal command built directly into
COMMAND.COM(such asDIR,COPY,CD, orDEL). If a match occurs, it executes internally, and no disk searching occurs. - Current Working Directory: If the command is not
internal, MS-DOS checks the current active directory on the current
drive. The current directory always takes precedence over the
PATHvariable, regardless of the paths configured inAUTOEXEC.BAT. - Sequential PATH Search: If the command is not found
in the current directory, MS-DOS parses the
PATHstring from left to right. It checks the first directory specified (e.g.,C:\DOS), looks for a matching executable, and if not found, proceeds to the next directory (e.g.,C:\WINDOWS).
If the command cannot be located after scanning the final directory
in the list, MS-DOS terminates the search and returns the error:
Bad command or file name.
Executable Extension Precedence
At each step of the directory search—both in the current directory
and along each entry in the PATH—MS-DOS 6.22 checks for
executable files using a rigid file-type hierarchy:
.COM(Compiled binary executable).EXE(Relocatable binary executable).BAT(Batch script interpreted byCOMMAND.COM)
For example, if a directory contains both PROGRAM.COM
and PROGRAM.EXE, invoking PROGRAM will always
launch PROGRAM.COM. MS-DOS only evaluates .EXE
if no matching .COM exists, and it only evaluates
.BAT if neither .COM nor .EXE is
present.
If a path entry points to a non-existent drive or deleted directory, MS-DOS simply skips that entry without throwing a boot error, continuing directly to the next delimited path in the sequence.