Introduction
This reference was written from the point-of-view that no one is writing batch programs
for MS-DOS, and that few people are writing batch programs for Windows 95. Most of the
reference material is based on Windows 2000 and XP, with notes about functionality
that differs between Windows 98 and 2000.
Batch file technology has evolved with each version of MS-DOS and early versions of Windows,
and is now supplanted at least partly by the Windows Scripting Host (WSH). WSH gives you much
greater flexibility and power because it lets you create scripts with powerful scripting
languages like VBScript and JavaScript.
Ansi.sys - a toy-box for batch-file developers - gave batch programs the capability
to change foreground and background colors, position the cursor, apply different text attributes,
redefine keyboard keys and assign commands to function keys. Beginning with Windows 98
Millenium, terminate-and-stay-resident (TSR) real-mode drivers like ansi.sys were
excluded from Windows startup in the attempt to reduce start-up time and improve stability
("device=" entries in config.sys are not processed unless you start in real mode).
Some of the capabilities provided by ansi.sys are available as environment variables,
accessible through the command shell using SET and CMD; other MS-DOS commands
are no longer available and some are replaced by new functionality built directly into Windows.
Commands
Batch file commands include the following:
- CALL - allows a batch file to call another batch file
- ECHO - suppresses or enables display of commands
- ENDLOCAL - ends localization of environment changes
- FOR - repeats processing on a set of files
- IF - tests for specific conditions
- GOTO - Directs processing to a line identified by a label
- NOT operator - Reverses the result of a true or false result in an IF command
- PAUSE - suspends execution
- REM - remark; comment
- SETLOCAL - changes environment variables for the batch file
- SHIFT - changes the position of parameters in a batch file
In addition to the standard batch file commands there are some DOS commands that are
particularly useful for batch programs:
- CHOICE - displays message and waits for user input
- CMD - loads a second command processor into memory
- EXIT - MS-DOS command, returns processing to calling program
- NUL - bit bucket for disposing of unwanted output
CALL
Allows a batch file to run another batch file and then continue execution of the
calling batch file.
Syntax:
CALL [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]]
Where
- [Drive:][Path] FileName is the path and filename of the batch program you
want to call. FileName must have a .bat or .cmd extension
- BatchParameters specifies any command-line information the batch program
you are calling requires, including command-line options, file names,
parameters %0-%9 (see Parameters in this reference), or variables (e.g.
%variableName%).
- :label specifies a label to which you want program control to jump.
Using CALL with this parameter creates a new batch program context
and passes control to the statement after the label. After jumping to a
label, the first time the end of the batch file is encountered control will
return to the statement after CALL. The second time the end of the
batch file is encountered, the script exits. See goto :eof for
another way to return from a batch script.
- arguments any command-line information that you pass to the new
instance of the batch program that begins at :label, including
command-line options, file names, parameters %1-%9, or variables (e.g.
%variableName%).
Notes:
- Availability: MS-DOS version 3.3 or later. Prior to version 3.3 you can use
COMMAND /C.
- If you don't use the CALL command (or COMMAND /C) to run another batch file from
your batch file (e.g. you run the second batch file by entering just the name
of the file in the first batch file), execution of all batch-file commands will
end when the second batch file completes execution - i.e. the remaining commands
in your batch file will not execute.
- Command extensions - by default, command extensions are enabled. In this case
CALL accepts a label as the target of the call. The syntax is
call :label arguments
- Recursive calls are allowed but you must provide an exit condition.
- Do not use pipes and redirection symbols with CALL.
Example
This batch file runs a second batch file using the CALL command:
VER
CALL bat2
bat2.bat contains the following commands:
SET PATH=%PATH%;C:\Temp
ECHO Path is now %PATH%
Output:
Microsoft Windows 2000 [Version 5.00.2195]
Path is now C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Temp
ECHO
Suppresses or enables the display of command names as MS-DOS executes the commands within a
batch file.
Syntax:
echo [{on|off}] [message]
Where
- {on|off} specifies whether the feature is on or off
- message is the text that will display on the screen
Notes:
- echo message is useful when echo is turned off, to display a message
while not displaying commands.
- Prevent display of a command by inserting an at (@) at the start of
the line.
- Use a carat (^) symbol to escape pipe and redirection characters for display.
Example 1
The following batch file contains the DATE and TIME commands. When you run the batch file,
DOS displays each command name as the command executes.
TIME
DATE
Output:
C:\> TIME
Current time is 22:11:50.50
Enter new time:
C:\> DATE
The current date is: Sat 06/30/2001
Enter new date: (mm-dd-yy)
Example 2
The following batch file suppresses command-name display with the @ECHO OFF command:
@ECHO OFF
TIME
DATE
Output:
Current time is 22:11:50.50
Enter new time:
The current date is: Sat 06/30/2001
Enter new date: (mm-dd-yy)
ENDLOCAL
Ends localization of environment changes by restoring environment variables to their values
before the matching SETLOCAL command.
Notes:
- ENDLOCAL is implicit at the end of a batch file.
- If you call ENDLOCAL, it must be within a batch file - if you call
ENDLOCAL outside of a script or batch file it has no effect.
- Changes to command extensions are restored to their state before SETLOCAL was
executed.
FOR
Repeats processing on a set of files.
Syntax:
for {%variable|%%variable} in (set) do command [ CommandLineOptions]
Where
- {%variable|%%variable}
- BatchVar is a single-character batch file variable (e.g. %%i)
- (set) is a comma- or space-separated list of files, or a file list designated
using the * or ? wildcard characters.
IF
IF is used to test for specific conditions. It has limited capabilities in batch
files, compared to other languages: there are three conditions that can be
tested. Including the NOT operator allows you to test the opposite condition.
First Form
Syntax:
IF ERRORLEVEL DOSCommand
Second Form
Syntax:
IF EXIST DOSCommand
Third Form
Syntax:
IF StringOne==StringTwo DOSCommand
GOTO
Directs processing to a line identified by a label. Processing begins on the line
following the label.
Where
- label specifies the line in a batch program that you want
processing to jump to.
Notes:
- You can jump to the end of a batch file using goto :EOF if command extensions
are enabled (the default). You do not need to place a :EOF label in the script.
Using goto :EOF allows you to exit a batch file, and is commonly used
to exit a second batch file that was called from another batch file. See the
description of CMD for information on command extensions.
- Label values can include letters, numbers, and spaces. Only the first
eight characters are used to identify a label. Labels must begin with a colon. Any
line that begins with a colon is recognized as a label and is not processed; any
commands on that line are ignored.
- The label value specified in a GOTO statement must match a label in
the batch file, otherwise processing stops and the message 'Label not found'
displays.
- GOTO can be used with other commands in conditional operations - see IF.
NOT operator
Reverses the result of a true or false result in an IF command.
Syntax:
IF NOT condition dos-command
PAUSE
Temporarily suspends execution and displays an optional message. Execution continues when
the user presses any key.
REM
Allows you to put remarks in a batch file.
Notes:
- REM does not display messages on the screen unless you set ECHO ON.
- You cannot use pipe or redirection characters in REM statements.
- You can use REM or blank lines to add vertical spacing on screen.
- The ECHO OFF command suppresses the display of remarks.
Example
You might include several lines at the top of your batch file that explain who wrote it,
when it was written, etc.
REM ftp database extract from host.
REM Author: G. Swanson
REM 2/10/1999
SETLOCAL
Changes (localizes) environment variables for the batch file. Localization ends when a
matching ENDLOCAL command is encountered or when the end of the batch file is reached.
Syntax:
setlocal {enableextension | disableextensions} {enabledelayedexpansion |
disabledelayedexpansion}
Where
- enableextension enables command extensions until ENDLOCAL
is encountered
- disableextensions disables command extensions until ENDLOCAL
is encountered
- enabledelayedexpansion enables delayed environment variable
expansion until ENDLOCAL is encountered
- disabledelayedexpansion disables delayed environment variable
expansion until ENDLOCAL is encountered
Notes:
- SETLOCAL is available within batch scripts only, calling it outside of
a script has no effect.
- You can nest SETLOCAL commands.
- When you call SETLOCAL, errorlevel is set to 0 if extensions are
available, otherwise errorlevel is set to 1. You can test errorlevel
to determine if
SHIFT
Changes the position of parameters in a batch file
Where
- /n is the (optional) argument where shifting begins, a
number from 0 to 8
Notes:
- Shift works on the parameters %0 through %9 by copying each parameter into the
previous parameter. The original value in %0 is no longer available after the shift.
For example,
SHIFT /3
would shift %4 into %3, %5 into %4, etc., without affecting %0, %1, or %2.
- Note that the /n argument is available only when command extensions are enabled.
- You can work with more than 10 parameters to a batch file by shifting the additional
parameters down into the range where they can be accessed.
CHOICE
Displays message and waits for user input. Input is defined as a set of keys
in the setup for CHOICE; the exit-status returned by CHOICE is used to
determine which key the user pressed.
Syntax:
CHOICE [/C[:]Keys][/N][/S][/T[:]Default,Seconds][Prompt]
Where
- /C specifies the set of keys; default is Y (yes) or N (no)
- /N prevents display of key choices and question mark
- /S specifies that CHOICE distinguish between upper and lower case keys
- /T is used to specify a default key and time in seconds (0-99), after
which CHOICE selects the default
- Prompt is the message displayed
Notes:
- Availability: started with MS-DOS version 6, ended with Windows 98 Millenium ed.
- CHOICE is an external MS-DOS command and must be in the search path
- Test exit-status using IF ERRORLEVEL
CMD
16-bit version is COMMAND
Loads a second command processor into memory. The command shell program provides direct
communication between the user and operating system. MS-DOS and Windows versions through
Windows 98 (pre-millenium edition) used COMMAND.COM to execute batch programs, while
later Windows versions use CMD.EXE. Windows Script Host runs more sophisticated
scripts in the command shell.
Syntax:
cmd [[{/c|/k}] [/s] [/q] [/d] [{/a|/u}] [/t:fg] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] string]
Where
- /c performs the command string and then terminates (exits program,
returns to command prompt)
- /k performs the command string and then continues (program waits
for more commands)
- /s modifies treatment of string that follows a /c or /k, regarding
quotation marks (see notes on processing quotation marks below)
- /q turns echo off
- /d disables cmd.exe's default behavior of executing AutoRun commands from
registry (see notes about executing registry subkeys below)
- /a creates ANSI output for internal commands sent to a pipe or file
- /u creates Unicode output for internal commands sent to a pipe or file
- /t:fg sets foreground f and background g colors (see notes
on setting foreground and background colors below)
- /e:on enable command extensions
- /e:off disable command extensions
- /f:on enable file and directory name completion characters
- /f:off disable file and directory name completion characters
- /v:on enable delayed environment variable expansion using c as the
delimiter
- /v:off disable delayed environment variable expansion
- string the command(s)
Notes:
- You can nest instances of command shell cmd.exe by calling cmd.
- Environment variables determine the behavior of the command shell and the
operating system. There are two types of environment variables: system and
local.
- Multiple commands
Multiple commands must be separated by the '&&' command separator and enclosed in
quotation marks: "command1&&command2&&command3"
- Processing quotation marks
If /c or /k is specified, the command line string following the switch is
processed based on the following conditions:
- /s is not used
- string contains one set of quote characters only
- the special characters &<>()@^| are not used in string
- one or more white-space characters are used in string
- the part of string between the quote characters is the name of an
executable file
If the above conditions are met, quote characters are preserved. Otherwise the
first character is stripped if it is a quote character, along with the closing
quote character, preserving all text between and following the quote characters.
- Executing registry subkeys
Cmd.exe's default behavior (i.e. when /d is not specified) is to look for
the following registry subkeys, and execute them before other variables:
- HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ
- HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun REG_EXPAND_SZ
- Setting foreground and background colors
Valid hexadecimal digits for f and g
| Value |
Color |
| 0 |
black |
| 1 |
blue |
| 2 |
green |
| 3 |
aqua |
| 4 |
red |
| 5 |
purple |
| 6 |
yellow |
| 7 |
white |
| 8 |
gray |
| 9 |
light blue |
| A |
light green |
| B |
light aqua |
| C |
light red |
| D |
light purple |
| E |
light yellow |
| F |
bright white |
EXIT
Use when calling another batch file from within a batch file. You must call EXIT
to return processing to the calling batch file.
Syntax:
exit [/b] [ExitCode]
Where
- /b exits the batch script
- exitcode is the return value of the script
Notes:
- If you use /b outside of a batch script, it will exit cmd.exe.
- When you use /b, the errorlevel is set by cmd.exe to the value
specified by exitcode. If you exit cmd.exe, exitcode is returned as
the process exit code.
NUL
The NUL device - referred to as a bit bucket - is useful for disposing of unwanted output.
Example
ECHO the following PAUSE command will display a prompt:
PAUSE
ECHO the following PAUSE command will not display a prompt:
PAUSE > NUL
Parameters
Parameters are the command-line arguments to your batch program. Cmd.exe provides variables
%0 through %9, with %0 reserved for the batch-file name. If you have more than 9 input
parameters to your batch program, you can use SHIFT to access them.
Modifiers
Modifiers expand batch parameters by taking drive and directory information and creating a
partial or complete file or directory name. The syntax is
%~modifier.
Modifiers you can use include the following:
| Modifier |
Description |
| %~1 |
Expands %1 and removes surrounding quotation marks. |
| %~f1 |
Expands %1 to a fully qualified path name. |
| %~d1 |
Expands %1 to a drive letter. |
| %~p1 |
Expands %1 to a path. |
| %~n1 |
Expands %1 to a file name. |
| %~x1 |
Expands %1 to a file extension. |
| %~s1 |
Expanded path contains short names only. |
| %~a1 |
Expands %1 to file attributes. |
| %~t1 |
Expands %1 to date and time of file. |
| %~z1 |
Expands %1 to size of file. |
| %~$PATH:1 |
Searches the directories listed in the PATH environment variable and expands
%1 to the fully qualified name of the first one found. If the environment variable
name is not defined or the file is not found, this modifier expands to the empty
string. |
You can get compound results using combinations of modifiers listed in the following table:
| Modifier |
Description |
| %~dp1 |
Expands %1 to a drive letter and path. |
| %~nx1 |
Expands %1 to a file name and extension. |
| %~dp$PATH:1 |
Searches the directories listed in the PATH environment variable for %1 and expands
to the drive letter and path of the first one found. |
| %~ftza1 |
Expands %1 to a dir-like output line. |
Filters
Filter commands give you control over the display of information your batch program processes.
Redirection operators are used with filter commands to determine their behavior.
- filter < filename sends input from a file to a filter command
- command | filter sends input from another command to a filter command
- filter < filename > filename2 sends input from a file to a filter command and
saves the result in filename2
Filter commands include the following:
- MORE - displays command output or file contents in one
command prompt window at a time
- FIND - searches files and command output for specified
characters
- SORT - orders files and command output alphabetically
MORE
Displays command output or file contents in one command prompt window at a time.
Syntax:
more [[/c] [/p] [/s] [/tn] [+n]] < [Drive:] [Path] FileName
Or
command | more [/c] [/p] [/s] [/tn] [+n]
Or
more [/c] [/p] [/s] [/tn] [+n] [files]
Where
- [Drive:] [Path] FileName is the file to display
- command is a command whos output you want to display
- /c clears the screen before display
- /p expands form-feed characters
- /s replaces multiple blank lines with one blank line
- /tn replaces tabs with n spaces
- +n specifies that display starts at line n of file
- files is a space-separated list of files to display
Notes:
- When the --More-- prompt appears you can press any
key on the keyboard (except Pause) to continue. Note the rules governing behavior
of the various keys below.
- Press CTRL+C to stop the command.
- Press SPACEBAR to display next page
- Press ENTER to display next line
- Press f to display next file
- Press q to quit
- Press ? to show available commands at --More--
prompt
- Press = to display line number at --More--
prompt
- Press pn to display next n lines
- Press sn to skip next n lines
Example
tree c:\inetpub | more
FIND
Searches files and command output for specified characters. Displays any lines that contain
the specified characters.
Syntax:
find [/v] [/c] [/n] [/i] "string" [[Drive:][Path]FileName[...]]
Where
- /v displays all lines that do not contain the characters specified
in string
- /c displays the total count of lines that contain the characters
specified in string
- /n precedes each line with the line number of the file
- /i specifies that the search is case-insensitive
- "string" the search text, enclosed in quotation characters
- [Drive:][Path] FileName is the location and name of the file to search
Notes:
- If quotation marks are part of the search text, escape them by using two quotation
marks for each occurrence.
- You can ommit filename and use FIND to filter input from the keyboard or a
pipe.
- Command-line options for FIND can be typed in any order.
- Wild-cards are not supported for file names or extensions specified with the
FIND command. Tip: if you need to use wild-cards, use FIND with a
FOR command.
- If you combine /c and /v in the same command line, FIND
displays a count of the lines that do not contain the search string. If you specify
/c and /n in the same command line, FIND ignores /n.
- FIND does not recognize carriage returns in the search text, and will not
include the carriage return or the text that follows in its search.
SORT
Reads input from the keyboard, pipe, or file; sorts the data, and writes the result to screen,
file, or another device.
Syntax:
sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1] [/t [drive2:][path2]] [/o [drive3:][path3]filename3]
Or
[command |] sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1][/t [drive2:][path2]] [/o [drive3:][path3]filename3]
Where
- /r reverses sort order
- /+n is the character position at which sort begins each
comparison
- /m kilobites is the amount of main memory to use for the sort
- /l locale will override the default sort order defined by the
system locale (i.e. the language and Country/Region selected when the
operating system was installed)
- /rec characters is the maximum number of characters in a record,
or a line of the input file (default is 4,096, max is 65,535).
- [drive1:][path1]filename1 specifies a file to sort. Omit file name
to sort the standard input
- /t [drive2:][path2] is the path to a working directory that
sort will use if it needs to temporarily store data that does not fit
in main memory.
- /o [drive3:][path3]filename3 is the output file where data
will be written. Omit file name to output data to the standard output
Notes:
- The sort command is case-insensitive.
- There is no limit on file size with the sort command.
- The minimum memory used by sort is 160 KB. When /m is used to specify
the amount of main memory to use, that amount will be used unless it is less than
160 KB.
- The maximum memory size when not specified with /m is 90 percent of available
main memory if both the input and output are files, and 45 percent otherwise.
- /l will produce a sort using the "C" local, which specifies that characters
should be sorted according to their binary encoding. This is faster than a natural
language sort.
- Use the pipe (|) symbol to direct the sort output to another command (e.g.
more). Other redirection symbols (e.g. <, >) used to specify an input
or output file may be less efficient than specifying the file as defined in the
syntax and using the /o parameter.
- Sort uses the collating-sequence table corresponding to the Country/Region code and
code-page setting. Sorting of characters above ASCII 127 is based on information
in country.sys, or an alternate file specified by the country entry in
config.nt.
- If the memory required by sort does not exceed the default 160 KB, or the memory
specified with the /m parameter, the operation is performed in one pass.
If the memory required by sort exceeds those amounts, the operation is
performed in two passes: a sort pass and a merge pass, with equal amounts of memory
allocated for both. In this case, partially sorted data is stored in a temporary
file on disk. If the sort operation requires more memory than is available to
complete the sort in two passes, a run-time error occurs. If the /m parameter
is used to specify more memory than is available, either performance degradation
or a run-time error occurs.
Example
To sort a file:
sort filename.txt
To sort output from a command - this example finds each line with the name "Swanson"
in the contacts.txt file and sorts the output:
find "Swanson" contacts.txt | sort
Redirection Operators
Redirection operators redirect command input and output stream locations. Stream location
is referred to as a handle. Handles have numeric values, three of which are pre-defined:
STDIN, STDOUT, and STDERR.
Default command input is sent via STDIN from the keyboard to the command processor
(command.com or cmd.exe). Default command output is sent via STDOUT from the command processor
to the Command Prompt window.
| Redirection operator |
Description |
| > |
Writes command output to a file or a device, such as a printer, instead of the
command prompt window. |
| < |
Reads command input from a file, instead of reading input from the keyboard. |
| >> |
Appends command output to the end of a file. |
| >& |
Writes the output from one handle to the input of another handle. |
| <& |
Reads the input from one handle and writes it to the output of another handle. |
| | |
Reads the output of one command and writes it to the input of another command. |
| Handle |
Value |
Description |
| STDIN |
0 |
Keyboard input. |
| STDOUT |
1 |
Output to the Command Prompt window. |
| STDERR |
2 |
Error output to the Command Prompt window. |
| UNDEFINED |
3-9 |
Application-defined and specific to each tool. |
If you do not specify a handle when using redirection operators with the command processor,
the default handle used by the < operator is zero (0) and the default handle used by
the > operator is one (1). The syntax for redirection to existing handles is as follows:
For example you can redirect STDERR into STDOUT with this command:
1<&2
Programming
Interrupting Batch File Execution
You can interrupt execution of the commands in a batch file by holding down the Ctrl key
and press C. DOS displays ^C and the message:
Terminate batch job (Y/N)?
If you press Y, DOS immediately stops processing the batch file. If you press N, DOS ends
the command it is currently executing, and continues execution with the next command.
Redirecting Output
You must specify I/O redirection on the specific command line(s) of the batch file if you
want to send output of the batch file somewhere other than the screen.
Syntax:
> creates a new file;
>> appends to the file.
Running One Command at a Time
When you have a batch file that is not working correctly, you can step through the file
to find out which command is causing the problem. Use the COMMAND batch file command with
the /Y and /C switches followed by the file name. DOS runs the file and stops at each
command, with a prompt that lets you run the command or skip it.
Syntax:
COMMAND /Y /C filename
Suspend Processing
When your batch file needs to wait until you perform some task, you can use the PAUSE
command to display a message, suspending execution until you press a key to continue.
When the PAUSE command executes, it displays the message specified in its command line
(if ECHO is not OFF), followed by the message:
Press any key to continue...
Command Cross Reference
View the list of commands at the command prompt on Windows 2000 by typing help and pressing
Enter. The HELP command is not available on Windows 98.
To view help for a command, open a command prompt (Windows 2000, XP) or DOS window (Windows
98) and enter /? command and press ENTER.
| Command |
98 |
2K |
Description |
| ASSOC |
N |
Y |
Displays or modifies file extension associations |
| AT |
N |
Y |
Schedules commands and programs to run on a computer. |
| ATTRIB |
Y |
Y |
Displays or changes file attributes. |
| BREAK |
Y |
Y |
Sets or clears extended CTRL+C checking. |
| CACLS |
N |
Y |
Displays or modifies access control lists (ACLs) of files. |
| CALL |
Y |
Y |
Calls one batch program from another. |
| CD |
Y |
Y |
Displays the name of or changes the current directory. |
| CHCP |
Y |
Y |
Displays or sets the active code page number. |
| CHDIR |
Y |
Y |
Displays the name of or changes the current directory. |
| CHKDSK |
Y |
Y |
Checks a disk and displays a status report. |
| CHKNTFS |
N |
Y |
Displays or modifies the checking of disk at boot time. |
| CHOICE |
Y |
N |
Displays message and waits for user input. |
| CLS |
Y |
Y |
Clears the screen. |
| CMD |
N |
Y |
Starts a new instance of the Windows 2000 command interpreter. |
| COLOR |
N |
Y |
Sets the default console foreground and background colors. |
| COMMAND |
Y |
N |
Starts a new instance of the command interpreter. |
| COMP |
N |
Y |
Compares the contents of two files or sets of files. |
| COMPACT |
N |
Y |
Displays or alters the compression of files on NTFS partitions. |
| CONVERT |
N |
Y |
Converts FAT volumes to NTFS. You cannot convert the current drive. |
| COPY |
Y |
Y |
Copies one or more files to another location. |
| CTTY |
Y |
N |
Changes the terminal device used to control your system. |
| DATE |
Y |
Y |
Displays or sets the date. |
| DEL |
Y |
Y |
Deletes one or more files. |
| DELTREE |
Y |
N |
Deletes a directory and all the subdirectories and files in it. |
| DIR |
Y |
Y |
Displays a list of files and subdirectories in a directory. |
| DISKCOMP |
N |
Y |
Compares the contents of two floppy disks. |
| DISKCOPY |
Y |
Y |
Copies the contents of one floppy disk to another. |
| DOSKEY |
Y |
Y |
Edits command lines, recalls Windows 2000 commands, and creates macros. |
| DRVSPACE |
Y |
N |
Displays list of drives and properties of each drive. |
| ECHO |
Y |
Y |
Displays messages, or turns command echoing on or off. |
| EMM386 |
Y |
N |
Turns on or off EMM386 expanded memory support. |
| ENDLOCAL |
N |
Y |
Ends localization of environment changes in a batch file. |
| ERASE |
Y |
Y |
Deletes one or more files. |
| EXIT |
Y |
Y |
Quits the CMD.EXE (Windows 2000) or Command.com (Windows 98) program (command interpreter). |
| FC |
Y |
Y |
Compares two files or sets of files, and displays the differences between them. |
| FDISK |
Y |
N |
Configures a hard disk for use with MS-DOS. |
| FIND |
Y |
Y |
Searches for a text string in a file or files. |
| FINDSTR |
N |
Y |
Searches for strings in files. |
| FOR |
Y |
Y |
Runs a specified command for each file in a set of files. |
| FORMAT |
Y |
Y |
Formats a disk for use with Windows 2000. |
| FTYPE |
N |
Y |
Displays or modifies file types used in file extension associations. |
| GOTO |
Y |
Y |
Directs the Windows 2000 command interpreter to a labeled line in a batch program. |
| GRAFTABL |
N |
Y |
Enables Windows 2000 to display an extended character set in graphics mode. |
| HELP |
N |
Y |
Provides Help information for Windows 2000 commands. |
| IF |
Y |
Y |
Performs conditional processing in batch programs. |
| LABEL |
Y |
Y |
Creates, changes, or deletes the volume label of a disk. |
| LOADHIGH |
Y |
N |
Loads a program into the upper memory area. |
| MD |
Y |
Y |
Creates a directory. |
| MEM |
Y |
N |
Displays the amount of used and free memory in your system. |
| MKDIR |
Y |
Y |
Creates a directory. |
| MODE |
Y |
Y |
Configures a system device. |
| MORE |
Y |
Y |
Displays output one screen at a time. |
| MOVE |
Y |
Y |
Moves one or more files from one directory to another directory. |
| MSCDEX |
Y |
N |
Configures the MS-DOS subsystem to use CD-ROM drives. |
| NLSFUNC |
Y |
N |
Loads country-specific information. |
| PATH |
Y |
Y |
Displays or sets a search path for executable files. |
| PAUSE |
Y |
Y |
Suspends processing of a batch file and displays a message. |
| POPD |
N |
Y |
Restores the previous value of the current directory saved by PUSHD. |
| PRINT |
N |
Y |
Prints a text file. |
| PROMPT |
Y |
Y |
Changes the Windows 2000 command prompt. |
| PUSHD |
N |
Y |
Saves the current directory then changes it. |
| RD |
Y |
Y |
Removes a directory. |
| RECOVER |
N |
Y |
Recovers readable information from a bad or defective disk. |
| REM |
Y |
Y |
Records comments (remarks) in batch files or CONFIG.SYS. |
| REN |
Y |
Y |
Renames a file or files. |
| RENAME |
Y |
Y |
Renames a file or files. |
| REPLACE |
N |
Y |
Replaces files. |
| RMDIR |
Y |
Y |
Removes a directory. |
| SCANDISK |
Y |
N |
Checks drive for errors. |
| SET |
Y |
Y |
Displays, sets, or removes Windows 2000 environment variables. |
| SETLOCAL |
N |
Y |
Begins localization of environment changes in a batch file. |
| SETVER |
Y |
N |
Sets the MS-DOS version number that Windows reports to a program. |
| SHIFT |
Y |
Y |
Shifts the position of replaceable parameters in batch files. |
| SMARTDRV |
Y |
N |
Installs and configures the SMARTDrive disk-caching utility. |
| SORT |
Y |
Y |
Sorts input. |
| START |
Y |
Y |
Starts a separate window to run a specified program or command. |
| SUBST |
Y |
Y |
Associates a path with a drive letter. |
| SYS |
Y |
N |
Copies MS-DOS system files and command interpreter to a disk you specify. |
| TIME |
Y |
Y |
Displays or sets the system time. |
| TITLE |
N |
Y |
Sets the window title for a CMD.EXE session. |
| TREE |
N |
Y |
Graphically displays the directory structure of a drive or path. |
| TYPE |
Y |
Y |
Displays the contents of a text file. |
| VER |
Y |
Y |
Displays the Windows 2000 version. |
| VERIFY |
Y |
Y |
Tells Windows 2000 whether to verify that your files are written correctly to a disk. |
| VOL |
Y |
Y |
Displays a disk volume label and serial number. |
| XCOPY |
Y |
Y |
Copies files and directory trees. |
References
Jamsa, Kris, 1994, Concise Guide to MS-DOS Batch Files: Microsoft Press, 218 pages.
ISBN 1-55615-638-3
Microsoft
TechNet online reference - search for "command-line reference."