How MS-DOS Resolves Command Name Conflicts
In MS-DOS 6.22, command execution relies on a strict internal
hierarchy within the primary command interpreter,
COMMAND.COM. When a user enters a command without
specifying a file path or extension, the operating system must decide
whether to run a built-in routine or search the disk for an executable
file. This article examines the exact precedence rules MS-DOS 6.22 uses
to resolve naming conflicts between internal shell commands and external
utilities, as well as the methods users can employ to override this
default behavior.
The Command Resolution Hierarchy
When a command is typed at the MS-DOS prompt,
COMMAND.COM parses the input string and resolves potential
name collisions using the following order of operations:
- Explicit Path or Extension Check: If the command
contains a file path (such as
C:\DOS\NAMEor.\NAME) or a file extension (such asNAME.EXE), MS-DOS bypasses the internal command table entirely and searches directly for the specified external file. - Internal Command Evaluation: If no path or
extension is specified,
COMMAND.COMchecks its hardcoded internal command table. If a match is found (such asDIR,COPY,DEL, orREN), the internal routine executes immediately in memory. External files sharing that name are ignored at this stage. - Current Working Directory Search: If the command is
not in the internal table,
COMMAND.COMinspects the current directory for executable files sharing the base name, checking extensions in a specific order:.COM.EXE.BAT
- PATH Environment Variable Traversal: If no matching
file is found in the current directory,
COMMAND.COMevaluates the directories specified in thePATHenvironment variable from left to right. Within each directory, it searches using the same file extension priority (.COM, then.EXE, then.BAT).
Internal Command Dominance
Internal commands are loaded directly into conventional memory as
part of COMMAND.COM during startup. Because they do not
require disk access, they execute faster than external programs.
Because internal commands sit at the top of the evaluation chain when
bare names are entered, creating an external utility named
DEL.EXE or COPY.BAT in the current working
directory will not naturally override the built-in DEL or
COPY commands. Typing DEL will always trigger
the internal deletion routine.
Overriding Internal Commands
To force MS-DOS 6.22 to execute an external utility that shares its name with an internal command, you must explicitly differentiate the input from a bare command:
- Specify the Extension: Typing
DEL.EXEorCOPY.BATforcesCOMMAND.COMto skip internal command matching and locate the external file matching that full filename. - Specify a Path: Prefixing the command with a
relative or absolute path (such as
.\DEL.EXEorC:\TOOLS\DIR.COM) explicitly instructs the interpreter to look on the disk rather than in its internal memory table.