Select the product you need help with
Order of Precedence in Locating Executable FilesArticle ID: 35284 - View products that this article applies to. This article was previously published under Q35284 On This PageSUMMARY
This article discusses the following:
MORE INFORMATIONCOMMAND.COMCOMMAND.COM can execute a file typed on the command line or as a line in a batch file.MS-DOS Versions Earlier Than Version 4.0When a filename is given, whether or not an extension is supplied, COMMAND.COM keeps the base name only. (COMMAND.COM removes the filename extension if one exists [for example, "FILE" remains if the filename is "FILE.EXE"]). After it has the base name, COMMAND.COM looks in the following order for an executable file that has this name:.COM .EXE .BAT
Bad command or file name
MS-DOS Versions 4.0 and LaterIn MS-DOS versions 4.0 and later, you can override the COM-EXE-BAT precedence by typing the command with the extension.For example, if there are three files in the current directory: FILE.COM, FILE.EXE, and FILE.BAT, and you try to execute any one of them by typing FILE.COM, FILE.EXE, or FILE.BAT, COMMAND.COM executes the one you specify. However, if no filename extension is given, the usual order of precedence is used (.COM, .EXE, and .BAT). One side effect of this behavior is that some incorrect or expedient ways of executing files no longer work. For example, in versions of MS-DOS earlier than 4.0, you can execute FILE.BAT by typing the filename with a period following it FILE.. However, in MS-DOS 4.0 and later, if you type FILE., MS-DOS searches for a file by this name, cannot find one, and returns a "bad command or file name" error message. MS-DOS Versions 5.0 and LaterMS-DOS versions 5.0 and later search for files in the following order:DOSKEY Macro .COM .EXE .BAT Also, in MS-DOS versions 5.0 and later, DOSKEY macros have precedence over internal commands. To override a DOSKEY macro, type one or more spaces before the command. EXEC FunctionThe MS-DOS EXEC function (interrupt 21h service 4Bh) does not understand filename extensions; therefore, it simply takes the name of the file specified when invoked and tries to execute it.This lack of filename information is an advantage to programs that have files that are executable. Such files are device drivers (which normally have the extension .SYS) or overlay files (which normally have the extension .OVL). COMMAND.COM cannot execute these files; only programs that explicitly call the EXEC function can run such programs. The EXEC function understands only the files that in most cases have .COM and .EXE extensions. It is not able to execute .BAT files; these files are specifically "executed", one line at a time, by COMMAND.COM. PropertiesArticle ID: 35284 - Last Review: May 10, 2003 - Revision: 2.0 APPLIES TO
|



Back to the top








