COMMAND.COM
Encyclopedia
COMMAND.COM is the filename of the default operating system shell
Shell (computing)
A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...

 for DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 operating systems and the default command line interpreter on Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...

, Windows 98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...

 and Windows Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....

. It has an additional role as the first program run after boot, hence being responsible for setting up the system by running the AUTOEXEC.BAT
AUTOEXEC.BAT
AUTOEXEC.BAT is a system file found originally on DOS-type operating systems. It is a plain-text batch file that is located in the root directory of the boot device...

 configuration file, and being the ancestor of all processes.
COMMAND.COM's successor on OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

 and Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

-based operating systems is cmd.exe
Command Prompt
Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

. COMMAND.COM is also available on 32-bit versions of those systems to provide compatibility when running DOS applications within the NT Virtual DOS machine.

Operating modes

As a shell, COMMAND.COM has two distinct modes of work. First is the interactive mode
Read-eval-print loop
A read–eval–print loop , also known as an interactive toplevel, is a simple, interactive computer programming environment. The term is most usually used to refer to a Lisp interactive environment, but can be applied to command line shells and similar environments for F#, Smalltalk, Standard ML,...

, in which the user types commands which are then executed immediately. The second is the batch mode
Batch processing
Batch processing is execution of a series of programs on a computer without manual intervention.Batch jobs are set up so they can be run to completion without manual intervention, so all input data is preselected through scripts or command-line parameters...

, which executes a predefined sequence of commands stored as a text file with the extension .BAT
Batch file
In DOS, OS/2, and Microsoft Windows, batch file is the name given to a type of script file, a text file containing a series of commands to be executed by the command interpreter....

.

Notable internal commands

All commands are run only after the Enter key is pressed at the end of the line. COMMAND.COM is not case-sensitive, meaning commands can be typed in either case and are all equivalent (so dir, DIR and DiR will all work in the same way).

File system commands

In accordance with COMMAND.COM's main function as an operating system shell, it includes a number of built-in commands for working with files.

In order to run a program, simply type the name of its executable and then press "Enter" (it is not necessary to use the extension, e.g. nc.exe can be summoned simply as nc). In order to change the current working drive (see Drive letter assignment
Drive letter assignment
Drive letter assignment is the process of assigning alphabetical identifiers to physical or logical disk drives or partitions in the root filesystem namespace; this usage is now mostly found in Microsoft operating systems...

), type its letter followed by a colon (e.g. D:). Other file system commands include:

DIR : Lists the files in the current directory
CD, CHDIR
Chdir
cd, sometimes also available as chdir , is a command line command to change the current working directory in operating systems such as Unix, DOS, OS/2, AmigaOS , Windows, and Linux...

 : Changes the current working directory
Working directory
In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...

 or displays the current directory.
COPY
Copy (command)
In computing, copy is a command in RT-11, RSX-11, OpenVMS, DOS, OS/2 and Microsoft Windows operating systems. The command copies computer files from one directory to another. The destination defaults to the current working directory. If more than one source file is indicated, the destination must...

 : Copies one file to another (if the destination file already exists, MS-DOS asks whether to replace it). (See also XCOPY
XCOPY
In computing, Xcopy is a command used on PC DOS, MS-DOS, OS/2, Microsoft Windows, and related operating systems for copying multiple files or entire directory trees from one directory to another and for copying files across a network...

, an external command that could also copy directory trees)
REN, RENAME
Ren (command)
In computing, ren is a command in various DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to rename files and in some implementations also directories. It is analogous to the Unix mv command...

 : Renames a file or directory
DEL, ERASE
Del (command)
In computing, del is a command in various DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to delete one or more files or directories from a filesystem. It is analogous to the Unix rm command...

 : Deletes a file. When used on a directory, deletes all files in that directory, but does not recurse or delete the directory itself.
MD, MKDIR
Mkdir
The mkdir command in the Unix, DOS, OS/2 and Microsoft Windows operating systems is used to make a new directory. In DOS, OS/2 and Windows the command is often abbreviated to md.-Usage:Normal usage is as straightforward as follows:...

 : Creates a new directory
RD, RMDIR
Rmdir
rmdir is a command which will remove an empty directory on a Unix, DOS, OS/2 or Microsoft Windows operating system. In Unix, Linux, and MacOS, it is case sensitive, whereas DOS, OS/2 and Windows , you can type the characters in any combination of upper case and lower case letters, and rd/rmdir...

 : Removes an empty directory
VOL
Vol (command)
In some operating systems vol is a command within the command line interpreters such as COMMAND.COM and cmd.exe...

 : Shows information about a volume
VERIFY : Enable or disable verification of writing for files
TYPE
Type (command)
In computing, type is a command in various VMS. AmigaDOS, CP/M, DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to display the contents of specified files...

 : Display the content of a file on the console
BREAK : Controls the handling of program interruption with Ctrl+C or Ctrl+Break.
CLS : Clears the screen.
CHCP : Displays or changes the current system code page
Code page
Code page is another term for character encoding. It consists of a table of values that describes the character set for a particular language. The term code page originated from IBM's EBCDIC-based mainframe systems, but many vendors use this term including Microsoft, SAP, and Oracle Corporation...

.
CTTY : Defines the device to use for input and output.
DATE
Time and date
In computing, time and date are commands that are used to display and set the current time and date of the operating system. Both commands are available in DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe and 4DOS/4NT. The Unix command date displays both the...

 : Display and/or set the date of the system.
ECHO : Toggles whether text is displayed (ECHO ON) or not (ECHO OFF). Also displays text on the screen (ECHO text).
LH, LOADHIGH : Loads a program into upper memory
Upper Memory Area
In DOS memory management, the upper memory area refers to memory between the addresses of 640 KB and 1024 KB in an IBM PC or compatible. IBM reserved the uppermost 384 KB of the 8088 CPU's 1024 KB address space for ROM, RAM on peripherals, and memory-mapped input/output...

 (HILOAD in DR DOS).
LOCK : Enables external programs to perform low-level disk access to a volume. (Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...

/98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...

/Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....

 only)
PATH : Displays or changes the value of the PATH environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

 which controls the places where COMMAND.COM will search for executable files.
PAUSE : Halts execution of the program and displays a message asking the user to press any key
Any key
Computer programmers historically used "Press any key to continue" as a prompt to the user when it was necessary to pause processing. The system would resume after the user pressed any keyboard button.-History:...

 to continue.
PROMPT : Displays or change the value of the PROMPT environment variable which controls the appearance of the prompt.
SET : Sets the value of an environment variable ; Without arguments, shows all defined environment variables.
TIME
Time and date
In computing, time and date are commands that are used to display and set the current time and date of the operating system. Both commands are available in DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe and 4DOS/4NT. The Unix command date displays both the...

 : Display and/or set the time of the system.
UNLOCK : Disables low-level disk access. (Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...

/98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...

/Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....

 only)
VER
Ver (command)
In computing, ver is a command in various DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe and 4DOS/4NT. It prints the name and version of the operating system or the command shell...

 : Displays the version of the operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

.
LFNFOR : Enables or disables the return of long filename
Long filename
Long filenames , are Microsoft's way of implementing filenames longer than the 8.3 filename, or short-filename, naming scheme used in Microsoft DOS in their modern FAT and NTFS filesystems. Because these filenames can be longer than an 8.3 filename, they can be more descriptive...

s by the FOR command. (Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...

/98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...

/Me
Windows Me
Windows Millennium Edition, or Windows Me , is a graphical operating system released on September 14, 2000 by Microsoft, and was the last operating system released in the Windows 9x series. Support for Windows Me ended on July 11, 2006....

 only)

Undocumented commands

Some versions of MS-DOS COMMAND.COM recognize some internal commands which were not documented.
TRUENAME : Display the "true name" of a file, by bypassing SUBST
Subst
subst is a command on the DOS, IBM OS/2 and Microsoft Windows operating systems used for substituting paths on physical and logical drives as virtual drives...

 and ASSIGN filesystem mappings.

Control structures

Control structures are mostly used inside batch files, although they can also be used interactively.

:label : Defines a target for GOTO.
FOR : Iteration: repeats a command for each out of a specified set of files.
GOTO : Moves execution to a specified label. Labels are specified at the beginning of a line, with a colon (:likethis).
REM : comment
Comment (computer programming)
In computer programming, a comment is a programming language construct used to embed programmer-readable annotations in the source code of a computer program. Those annotations are potentially significant to programmers but typically ignorable to compilers and interpreters. Comments are usually...

: any text following this command is ignored
IF : Conditional statement, allows to branch the program execution
CALL : Pauses execution of one batch file, runs another, and returns to the old one and continues.
EXIT : Exits from Command.com and returns to the program which launched it.
SHIFT : Replaces each of the command-line variables with the consequent one (e.g. %0 with %1, %1 with %2 etc. )

Variables

Batch files for COMMAND.COM can be said to have four kinds of variables:
  1. ERRORLEVEL - contains the return code of the last program to run that sets a value (an integer between 0 and 255). Most programs have a certain convention for their return codes (for instance, 0 for a successful execution). Some programs do not establish a new value, and thus the older value persists after they execute. The value of ERRORLEVEL is tested for range with the IF statement.
  2. Environment variable
    Environment variable
    Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

    s - these have the form %VARIABLE% and are associated with values with the SET statement. Most versions of COMMAND.COM will only expand environment variables in batch mode.
  3. Command-line parameters - these have the form %0, %1...%9, and initially contain the command name and the first nine command line parameters passed to the script (e.g., if the invoking command was "myscript.bat John Doe", then %0 is "myscript.bat", %1 is "John" and %2 is "Doe"). The parameters to the right of the ninth can be mapped into range by using the SHIFT statement.
  4. "For" variables - used by loops, have the format %%a when run in batch files. These variables are defined solely within a specific FOR statement, and iterate over a certain set of values defined in that FOR statement.

Redirection, piping, and chaining

Because DOS is a single-tasking operating system, piping
Pipeline (software)
In software engineering, a pipeline consists of a chain of processing elements , arranged so that the output of each element is the input of the next. Usually some amount of buffering is provided between consecutive elements...

 is achieved by running commands sequentially, redirecting to and from a temporary file
Temporary file
Temporary files may be created by computer programs for a variety of purposes; principally when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than the architecture's address space, or as a primitive form of inter-process communication.- Auxiliary...

. COMMAND.COM makes no provision for redirecting the standard error channel.

command < filename : Redirect standard input from a file or device
command > filename : Redirect standard output, overwriting target file if it exists.
command >> filename : Redirect standard output, appending to target file if it exists.
command1 | command2 : Pipe standard output from command1 to standard input of command2
command1 & command2 : Commands separated by & are executed in sequence (=chaining of commands). In other words: first command1 is executed until termination, then command2.

Limitations

The command line length in interactive mode is limited to 128 characters.
It always returns a true value upon executing a command.

Cultural references

“Loading COMMAND.COM” message can be seen on a HUD
Head-Up Display
A head-up display or heads-up display is any transparent display that presents data without requiring users to look away from their usual viewpoints...

 view of the Terminator
T-800
"The Terminator" refers to a number of fictional characters portrayed by Arnold Schwarzenegger – a cyborg, initially portrayed as a programmable assassin and military infiltration unit...

 and the internal viewport of RoboCop
RoboCop
RoboCop is a 1987 American science fiction-action film directed by Paul Verhoeven. Set in a crime-ridden Detroit, Michigan in the near future, RoboCop centers on a police officer who is brutally murdered and subsequently re-created as a super-human cyborg known as "RoboCop"...

 when he reboots. The COMMAND.COM is also a position of authority in the show ReBoot
ReBoot
ReBoot is a Canadian CGI-animated action-adventure cartoon series that originally aired from 1994 to 2001. It was produced by Vancouver-based production company Mainframe Entertainment, Alliance Communications, BLT Productions and created by Gavin Blair, Ian Pearson, Phil Mitchell and John Grace,...

.

For several years, the command.com domain hosted a website with an image of a command prompt with the "dir" command being run. It was apparently meant to trick users into thinking the contents of their "C:" drive were listed. However, the resulting command incorrectly displayed the . and .. directories, which are never shown in the root of a drive. (The domain was later sold and is now used for commercial purposes.)

See also

  • 4DOS
    4DOS
    4DOS is a command line interpreter by JP Software, designed to replace the default command interpreter COMMAND.COM in DOS and Windows 95/98/Me. The 4DOS family of programs are meant to replace the default command processor. 4OS2 and 4NT replace CMD.EXE in OS/2 and Windows NT respectively...

     - designed to replace COMMAND.COM
  • CMD.EXE
    Cmd.exe
    Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

  • Comparison of computer shells
    Comparison of computer shells
    A command shell is a command line interface computer program to an operating system.- General characteristics :- Interactive features :- Programming features :- Syntax :- Data types :- String and filename matching :...

  • List of DOS commands

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK