Executable Search Order in DOS When you type a command at the DOS prompt without an extension, in what order does COMMAND.COM search for executable files?
-
AEXE, COM, BAT
-
BEXE, BAT, COM
-
CCOM, EXE, BAT
-
DBAT, COM, EXE
-
ENone of the above
Answer
Correct Answer: COM, EXE, BAT
Explanation
Introduction / Context:Command resolution is the process the shell uses to find and start the program you request. DOS’s COMMAND.COM follows a consistent search order for extensions when none is specified at the prompt, which affects which file actually runs if multiple variants exist.
Given Data / Assumptions:
- Standard COMMAND.COM behavior.
- PATH variable may direct the search across directories, but the extension priority stays the same.
- Files of the same base name may exist with different extensions in the same directory.
Concept / Approach:COMMAND.COM first looks for a .COM file, then for a .EXE file, and finally for a .BAT file. This means a tiny .COM utility can shadow an .EXE or .BAT with the same name, leading to different behavior than expected.
Step-by-Step Solution:User types FOO at the prompt.COMMAND.COM checks for FOO.COM; if present, it runs.If not found, it checks for FOO.EXE; if present, it runs.If neither is found, it checks for FOO.BAT and runs it if available.
Verification / Alternative check:Create FOO.COM, FOO.EXE, and FOO.BAT in the same directory with distinctive output. Typing FOO will execute FOO.COM first, verifying the order COM → EXE → BAT.
Why Other Options Are Wrong:Options A, B, and D list orders that contradict DOS’s documented behavior.Option E is incorrect because there is a definitive, standard order.
Common Pitfalls:
- Unexpectedly running a .COM utility when intending to run a .BAT script with the same name.
- Security implications: placing a rogue .COM earlier in PATH can hijack execution.
Final Answer:COM, EXE, BAT