• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Part III: Appendixes > Built-In Commands

Built-In Commands

Table D.7 lists the built-in commands implemented by CMD.

Table D.7. Built-in Commands
Command Purpose
@command Executes command without echoing it to the console.
:label Identifies the target of goto label or call :label.
assoc Associates file extensions with file types.
break Causes a breakpoint in debugger; otherwise, it has no effect.
call batchfile [arguments…] Performs a “subroutine” call.
call :label [arguments…]  
cd [[drive:]directory] Changes the current working directory.
chdir [[drive:]directory] Same as cd.
cls Clears the screen (window).
color bf Changes the screen color to b and the text color to f, using the codes listed in Table 11.5.
copy [/d][/v][/n][/y|/-y]
   source [/a|/b]
   [+source [/a|/b]]...
   [destination [/a|/b]]

Copies files or folders from source to destination. The options are:

/d— Decrypt files

/v— Verify file integrity

/y— Don't confirm overwrite

/z— Network file copy

/a— Use eASCII interpretation

/b— Use binary interpretation

date [/t | mm-dd-yyyy] Displays or sets the date. /t means don't prompt for a new date.
del filename ...[/p|/q][/f][/s]

Deletes files, bypassing the Recycle Bin. The options are:

/p— Prompt to confirm

/f— Delete read-only files

/s— Delete files in all subdirectories

/q— Do not confirm

/a— Delete files with specified attributes

The attribute codes are:

R— Read-Only

S— System

H— Hidden

A— Archive

Note that - before S, H, R, or A means to “select the file if the attribute is not set.”
dir pathname ...

Displays lists of files and/or folders in directories. The options are:

/p— Pause every screen full

/q— Display file owners' names

/w— Multicolumn wide listing

/d— Like /w but sorts columns

/n— Long list format

/x— Display 8.3 names

/b— Brief listing: names only

/s— Recurse into subfolders

/l— Display names in lowercase

/c— Use 1000's separators

/4— Use four-digit year format

/a— Select by attributes

/o— Set sort order

/t— Choose time field for sort or time to display

echo on|off Enables or disables echo.
echo text Types text.
echo. Types a blank line.
endlocal Restores variables and settings to pre-setlocalvalues.
erase Same as del.
exit [/b] [exitcode] Terminates the command or batch file. /b means terminate batch, not CMD.
for [modifier] %variable in (list) do command Executes command for each item in list. List can contain wildcards to match filenames. Variable is a single, case-sensitive letter that may be substituted anywhere in command or arguments using the replacement options listed in Table D.3. See Table D.7 for the modifier options. Use %% in batch files.
ftype filetype

Displays or sets associations from file types to the “file open” command.
goto label Jumps to label.
goto :EOF Jumps to end of file.
if condition command
if condition (command) else
if condition (
) else (

[not] strng1 == strng2
[not] errorlevel number
[not] exist filename
[/i] strng1 compareop strng2
cmdextversion number
defined variable

Executes command if the condition is true. The optional else command is executed if the condition is not true. Commands can span more than one line if enclosed in parentheses.

Compareops are as follows:

EQU— Equal to

NEQ— Not equal to

LSS— Less than

LEQ— Less than or equal to

GTR— Greater than

GEQ— Greater than or equal to

/i means ignore case in comparison.
md pathname Creates directory path.
mkdir pathname Same as md.
move [/y|/-y] frompath topath Moves files or folders. Here's the one option:

/y— Don't confirm overwrite

path [folder[;folder…] Sets the search path and path environment variable.
pause Prints “Press any key to continue” and waits.
popd Restores the previous current directory saved by pushd.
prompt TextAndCodes Sets the command prompt string and the prompt environment variable.
pushd path Changes the directory and can also map a network drive.
rd [/s] [/q] path Removes the directory named by path. With /s, it recursively deletes all subdirectories. Option /q suppresses the confirmation prompt.
rem text Remark text.
rename oldname newname Renames files or folders.
rmdir [/s] [/q] path Same as rd.
set [name[=[value]]] Sets or displays an environment variable.
set /a expression Calculates an arithmetic expression. See Table D.2.
set /p name=promptstring Prompts for input.

Saves environment variables, the working directory, and option settings.
shift [/n] Shifts batch arguments. /n means shift from argument n.
start "title" [/dpath] [/i]
 [/min | /max]
 [/separate | /shared]
 [/low    | /belownormal |
  /normal | /abovenormal |
  /high   | /realtime]
 [/wait] [/b]
 command [arguments]

Starts a command in a new window. The options are:

/d— Set default directory

/i— Use initial environment

/min— Start minimized

/max— Start maximized

/separate— Separate Win16 process

/shared— Common Win16 process

/low/realtime— priority

/wait— Wait for exit

/b— Use same window

time [/t | hh:mm:ss] Displays or sets the time. /t means don't prompt for new time.
title [string] Sets the window title.
type filename Writes a file's contents to the standard output.
ver Displays the Windows version.
vol [drive:] Displays the disk volume label.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint