Home
> Commands A-M
> Commands Ch-Cz
COMMAND
Description
| Syntax
| Parameters
| Switches
| Related
| Notes
| Examples
| Errorlevels
| Availability
Starts a new instance of the operating system command interpreter.
A command interpreter is a program that lets you type commands.
Use EXIT to stop the new command interpreter and return
control to the old one.
Syntax
COMMAND
/?
COMMAND
[[drive:]path]
[device]
[/D]
[/E:nnnnn]
[/F]
[/LOW]
[/T]
[/Z]
[[/P
[/L:nnnn]
[/U:nnn]
[/MSG]]
[[/Y
[/C command
| [/K command]]
In your CONFIG.SYS file:
SHELL=
[[dos-drive:]dos-path]
COMMAND.COM
[[drive:]path]
[device]
[/E:nnnnn]
[/F]
[/LOW]
[[/P
[/L:nnnn]
[/U:nnn]
[/MSG]]
Parameters
- [drive:]path
(v2.0
Win95
NT4)
- Specifies the directory in which the command interpreter is
to look for the COMMAND.COM file when the transient part of the
program needs to be reloaded. This parameter must be included
when loading COMMAND.COM for the first time if the COMMAND.COM
file is not located in the root directory. This parameter is used
to set the %COMSPEC% environment variable. For more information,
see Transient and Resident Memory in
COMMAND--Notes.
Specifies the drive location (if other than the current drive)
to which you want to change.
- device
(v2.0
Win95
NT4)
- Specifies a different device for command input and output.
For more information about this parameter, see the
CTTY command.
- [dos-drive:]dos-path
(v2.0
Win95)
- Specifies the location of the COMMAND.COM file.
Switches
- /?
(NTXP)
- Display help.
- /C command
(v2.0
Win95
NT4)
- Specifies that the command interpreter is to perform the
specified command and then exit. This switch must be the last
switch on the command-line.
- /D
(v5.0)
- UNDOCUMENTED Temporarily undoes the
/F switch. Type
EXIT to return to the auto-fail
version of DOS. Use at the DOS prompt or in batch files only.
- /E:nnnnn
(v2.0
Win95
NT4)
- Specifies the initial environment size, where nnnnn is the
size in bytes. The value of nnnnn must be in the range 160
(256 beginning with
v7.00 and
Win95)
through 32768. The operating system rounds this number up to a
multiple of 16 bytes. The default value is 256.
- /F
(v3.30)
- UNDOCUMENTED Forces a "automatic" FAIL response to the
COMMAND floppy disk drive error message: ABORT, RETRY, FAIL?
- /K command
(v6.0
Win95)
- Runs the specified command, program, or batch program and
then displays the operating system command prompt. This switch
must be the last switch on the COMMAND command-line.
- This switch is particularly useful for specifying a startup
batch file for the operating system prompt in Windows (much
like AUTOEXEC.BAT for the operating system). To do this,
open the DOSPRMPT.PIF file using the PIF Editor, and type
the /K switch in the Optional Parameters box. It is not
recommended to use the /K switch on the SHELL command-line
in your CONFIG.SYS file; doing so can cause problems with
applications and installation programs that make changes
to your AUTOEXEC.BAT file.
- /L:nnnn
(v7.00
Win95)
- Specifies the internal buffers length. The value of nnnn must
be in the range 128 through 1024. You must specify the
/P switch when you use the /L switch.
- /LOW
(v7.00
Win95)
- Forces resident COMMAND data to be kept in low memory.
- /MSG
(v6.0
Win95
NT4)
- Specifies that all error messages should be stored in memory.
Usually, some messages are stored only on disk. This switch is
useful only if you are running the operating system from floppy
disks. You must specify the /P switch when
you use the /MSG switch. For more information about using the
/MSG switch, see
COMMAND--Notes.
- /P
(v3.20
Win95
NT4)
- Should be used only when COMMAND is used with the SHELL
command in the CONFIG.SYS file. The /P switch makes the new copy
of the command interpreter permanent. In this case,
EXIT
cannot be used to stop the command interpreter. If you
specify /P, the operating system runs your AUTOEXEC.BAT file
before displaying the command prompt. If there is no
AUTOEXEC.BAT file in the root directory of the startup drive,
the operating system carries out the
DATE and
TIME commands instead. If you do
not have a SHELL command in your
CONFIG.SYS file, COMMAND.COM is automatically loaded from the
root directory with the /P switch.
- /T
(v7.00
Win95)
- UNDOCUMENTED Forces resident COMMAND data to be
kept in low memory.
- /U:nnn
(v7.00
Win95)
- Specifies the input buffer length. The value of nnn must be
in the range 128 through 255. You must specify the
/P switch when you use the /U switch.
- /Y
(v6.0
Win95)
- Directs COMMAND.COM to step through the batch file specified
by the /C or /K
switches. This switch is useful for debugging batch files. For
example, to step through the TEST.BAT batch file line by line,
you would type COMMAND /Y /C TEST. The /Y
switch requires either the /C or the
/K switch.
- /Z
(v7.00
Win95)
- UNDOCUMENTED Appends errorlevel to external command
output.
Related
SHELL command is the preferred method of using COMMAND
to permanently increase space for the environment table.
Notes
Limits on environment size
If /E:nnnnn is less than 160
or greater than 32768, DOS uses the default value of 256 bytes
and displays the message:
Parameter value not in allowed range.
Changing your terminal device
You can specify a different device (such as AUX) for input and
output by using the device parameter. For more information about
device, see the CTTY command.
Running multiple command interpreters
When you start a new command interpreter, the operating system
creates a new command environment. This new environment is a copy
of the parent environment. You can change the new environment
without affecting the old one. The default size of the new
environment is 256 bytes or the size of the current environment
rounded up to the next 16 bytes, whichever is larger. Use the
/E switch to override the
default size. (Note that the current environment refers to the
memory actually being used, not to the environment size specified
with the previous /E switch.)
Transient and resident memory
The operating system loads the command interpreter in two
parts: the resident part (which is always in memory) and the
transient part (at the top of conventional memory). Some programs
write over the transient part of COMMAND.COM when they run. When
this happens, the resident part must locate the COMMAND.COM file
on disk to reload the transient part. The
%COMSPEC% environment
variable identifies where
COMMAND.COM is located on the disk. If
%COMSPEC% is set to a
floppy disk drive, the operating system might prompt you to
insert a disk that contains COMMAND.COM.
If the operating system is loaded in the HMA, a portion of
resident COMMAND.COM is also loaded into the HMA, making more
conventional memory available for programs.
Using the /MSG switch
Usually, the operating system leaves many error messages
in the COMMAND.COM file on the disk instead of using memory to
store them. When the operating system needs to display one of
these messages, the operating system retrieves the message from
the disk containing COMMAND.COM.
If you are running the operating system from floppy disks
instead of from a hard disk, the operating system cannot retrieve
such error messages unless you have the disk containing
COMMAND.COM in drive A. If this disk is not present, the operating
system displays one of the short messages instead of the
full message:
Parse error
Extended error
You can make sure the operating system displays complete error
messages by using the /MSG switch with
COMMAND. This switch forces the operating system to keep these
error messages in memory so that they are always available when
needed.
Use the /MSG switch with
COMMAND if you have a floppy disk system, unless you cannot
afford to lose the memory used to store the error messages.
You must also specify the /P
switch when you use the /MSG
switch.
Internal commands
COMMAND is called a command processor because it reads any
commands that you type and processes them.
Some commands are recognized and carried out by COMMAND itself.
These commands are considered internal to COMMAND. Other operating
system commands are separate programs located on your hard disk,
which the operating system loads just like your other programs.
The following operating system commands are implemented by
COMMAND:
Examples
The following command specifies that the operating system command
interpreter is to start a new command interpreter from the current
program, run a batch program named MYBAT.BAT, and then return to
the first command interpreter:
COMMAND /C mybat.bat
The following CONFIG.SYS command specifies that COMMAND.COM is
located in the DOS directory on drive C:
SHELL=c:\dos\command.com C:\DOS\ /E:1024
This command directs the operating system to set the
%COMSPEC% environment
variable to C:\DOS\COMMAND.COM. This command also creates an
environment of 1024 bytes for this command interpreter.
The following command starts an instance of COMMAND.COM and runs
the MYBATCH.BAT file, stepping through the file command by
command:
COMMAND /Y /C mybatch.bat
Errorlevels
none.
Availability
- External
-
- DOS
-
v1.0
v1.05
v1.1
v1.11
v1.24
v1.25
v1.85
v2.0
v2.01
v2.05
v2.10
v2.11
v2.11R
v2.12
v2.2
v2.25
v3.0
v3.20
v3.05
v3.1
v3.21
v3.25
v3.30
v3.3A
v3.3R
v3.3T
v3.31
v3.40
v4.0
v4.01
v4.01A
v5.0
v5.0A
v5.00.02
v5.001A
v5.01
v5.02
v6.0
v6.10
v6.2
v6.21
v6.22
v6.23
v7.00
v7.0R1
v7.10
v8.00
- Windows
-
Win95
Win98
WinME
- Windows NT
-
NT4
NT2000
NTXP
Last Updated: 2004/03/01
Direct corrections or suggestions to:
Rick Lively