![]() Windows 8上的COMMAND.COM | |
其他名称 | MS-DOS Prompt, Windows Command Interpreter |
---|---|
開發者 | Seattle Computer Products, IBM, Microsoft, The Software Link, Datalight, Novell, Caldera |
首次发布 | 1980年 |
编程语言 | x86 汇编语言[1] |
操作系统 |
|
平台 | 16位 x86 |
由…取代 | cmd.exe |
类型 | 命令行解释器 |
COMMAND.COM是MS-DOS、Windows 95、Windows 98、Windows 98SE和Windows Me下默认的命令行解释器。在DOS环境下,它也是默认用户界面。它一般还是系统启动后运行的第一个程序(即init),因此负责运行AUTOEXEC.BAT配置文件以设置系统环境,也是所有进程的父进程。
COMMAND.COM在OS/2和Windows NT上的继任者是cmd.exe。即便如此,COMMAND.COM在这些系统的IA-32版本上的DOS虚拟机中仍然可用。
文件名COMMAND.COM也被Disk Control Program (DCP)——前东德公司VEB Robotron发行的MS-DOS变体使用。[2]
FreeDOS下与之兼容的命令处理程序有时也称作FreeCom。
COMMAND.COM是DOS程序。由COMMAND.COM启动的程序都是DOS程序,调用DOS API与磁盘操作系统通信。
作为一个用户界面,COMMAND.COM有两种截然不同的操作模式。第一种是交互模式,用户输入的指令会被立即执行;第二种是批处理模式,负责执行存储在名称以.BAT结尾文本文件中的一组预定义命令。
内部命令是直接存储于COMMAND.COM二进制文件中的命令。因此,它们一直可用,但只能直接执行于命令直译器。
当↵ Enter键在一行末尾按下后,所有命令才被执行。COMMAND.COM不区分大小写,也就是说命令可以按照任意大小写组合输入。
ECHO ON
) 或关闭(ECHO OFF
)。也用于在屏幕上显示字符(ECHO text
)。HILOAD
)。控制结构多用于批处理文件中,即使也可以在交互模式下使用。[4][3]
:likethis
)。%1
替代%0
,用%2
替代%1
等)在退出的时候,所有外部命令都会向调用者给出一个介于 0 到 255 之间的返回码。绝大多数程序对于它们的返回码有一些约定,例如使用 0 表示成功执行。[5][6][7][8]
如果程序是由 COMMAND.COM 调用的,那么使用 ERRORLEVEL 作为条件句的 IF 内部命令可以用于判断最后调用的外部程序的错误状态。
在 COMMAND.COM 中,内部命令不产生新的值。
COMMAND.COM批处理文件允许四种变量类型:
%VARIABLE%
,使用 SET 语句赋值。在 DOS 3 之前,COMMAND.COM 仅会在批处理模式中展开环境变量,或者说在命令提示符中不能使用。[來源請求]%0
, %1
...%9
,默认包含命令名称和传递给脚本的前九个命令行参数(例如,如果调用命令“myscript.bat John Doe
”,那么 %0
是 “myscript.bat
”,%1
是“John
”,%2
是“Doe
”)。第九个之后的参数可以使用 SHIFT 语句移动到前九个的范围内。%%a
,使用于循环中。这些变量仅由一个特定的 FOR 语句定义,然后在该语句中遍历一系列给定的值。由于DOS是单用户操作系统,管道由按顺序执行多个命令并重定向到临时文件(或从临时文件重定向)实现。COMMAND.COM不支持重定向到标准错误输出。
command < filename
command > filename
command >> filename
command1 | command2
command1 ¶ command2
&
分隔符,以提供与OS/2及Windows NT系列cmd语法的兼容性(然而cmd不支持¶分隔符)。[9]交互模式下命令行长度不得超过126字符。[11][12][13]在MS-DOS 6.2.2中,交互模式的命令行长度限制为127字符。
当终结者重新启动时,在终结者的HUD视图中和机械战警的内部视图中显示有“正在加载 COMMAND.COM”(Loading COMMAND.COM)。
在计算机制作的动画连续剧ReBoot中(该剧的背景发生在计算机内部),系统(相当于城市)的领导者被称为 COMMAND.COM。
NWDOSTIP.TXT
, which is part of the MPDOSTIP.ZIP
collection.) [1]
[…] Multiple Commands: You can type several commands on the same command line, separated by a caret [^]. For example, if you know you want to copy all of your .TXT files to drive A: and then run CHKDSK to be sure that drive A's file structure is in good shape, you could enter the following command:C:\>COPY *.TXT A: ^ CHKDSK A:
You may put as many commands on the command line as you wish, as long as the total length of the command line does not exceed 511 characters. You can use multiple commands in aliases and batch files as well as at the command line. If you don't like using the default command separator, you can pick another character using the SETDOS /C command or the CommandSep directive in 4DOS.INI. […] SETDOS /C: (Compound character) This option sets the character used for separating multiple commands on the same line. The default is the caret [^]. You cannot use any of the redirection characters [<>|], or the blank, tab, comma, or equal sign as the command separator. The command separator is saved by SETLOCAL and restored by ENDLOCAL. This example changes the separator to a tilde [~]:C:\>SETDOS /C~
(You can specify either the character itself, or its ASCII code as a decimal number, or a hexadecimal number preceded by 0x.) […] CommandSep = c (^): This is the character used to separate multiple commands on the same line. […] Special Character Compatibility: If you use two or more of our products, or if you want to share aliases and batch files with users of different products, you need to be aware of the differences in three important characters: the Command Separator […], the Escape Character […], and the Parameter Character […]. The default values of each of these characters in each product is shown in the following chart: […] Product, Separator, Escape Parameter […] 4DOS: ^, ↑, & […] 4OS2, 4NT, Take Command: &, ^, $ […] (The up-arrow [↑] represents the ASCII Ctrl-X character, numeric value 24.) […]
4DOS5TIP.TXT
file, which is part of the MPDOSTIP.ZIP
collection.) [5]
[…] all MS-DOS versions prior to Windows 95 […] used a COM style COMMAND.COM file which has a special signature at the start of the file […] queried by the MS-DOS BIOS before it loads the shell, but not by the DR-DOS BIOS […] COMMAND.COM would […] check that it is running on the "correct" DOS version, so if you would load their COMMAND.COM under DR-DOS, you would receive a "Bad version" error message and their COMMAND.COM would exit, so DR-DOS would […] display an error message "Bad or missing command interpreter" (if DR-DOS was trying to load the SHELL= command processor after having finished CONFIG.SYS processing). In this case, you could enter the path to a valid DR-DOS COMMAND.COM (C:\DRDOS\COMMAND.COM) and everything was fine. Now, things have changed since MS-DOS 7.0 […] COMMAND.COM has internally become an EXE style file, so there is no magic […] signature […] to check […] thus no way for DR-DOS to rule out an incompatible COMMAND.COM. Further, their COMMAND.COM no longer does any version checks, but […] does not work under DR-DOS […] just crashes […] the PC DOS COMMAND.COM works fine under DR-DOS […][8][9]
|
|