Programming Field

DOS/Command Prompt Reference

This page includes command references for MS-DOS Prompt and Windows Command Prompt. Some command references have samples for the prompt and the batch files.

Command list

Currently only a few command references are available in English. More references are available in Japanese here: DOS/コマンドプロンプト コマンド一覧

Notes
  • On this site, ‘Windows NT series’ means Windows NT/2000/XP or later environments or ‘cmd.exe’ environments (Not all Windows versions are researched). ‘command.com’ environment may be differ from ‘cmd.exe’ environment.
  • Commands/Programs
    CallExecutes a batch program from a batch program without terminating. Or executes subroutines.
    CdChanges the current directory.
    ChcpDisplays/changes the code page for the current session.
    ChdirChanges the current directory.
    ClsClears all output in the screen.
    CopyCopies the file(s).
    DateDisplays and changes the system date.
    EchoOutputs text to the screen. Also toggles prompt display.
    EndlocalEnds localization of environment changes.
    ExitExits the prompt.
    FindSearches for the string from the file.
    ForExecutes a command for each files or texts matching with the specified pattern.
    IfExecutes a command when specified condition is met.
    MoreDisplays the long output per screen.
    MoveMoves the file(s).
    PauseStops (pauses) the execution and prompts for any key input.
    PopdRestores Pushd's directory change just before.
    PushdChanges the current directory. The current directory can be restored by calling Popd.
    PromptSets/changes the prompt display.
    RemDoes nothing. Used for writing comments in batch files.
    RenChanges the name of the file.
    RenameChanges the name of the file.
    SetDisplays or modifies environment variables.
    SetlocalBegins localization of environment changes, making environment variable changes or etc. temporary.
    ShiftShifts parameters, specified to the batch program, and enables to use 10 or more parameters.
    SortSorts each line of input data and prints the result.
    TimeDisplays and changes the system time setting.
    TypeOutputs the file content.
    VerifySets whether to verify writing a file to a disk.
    * Command is an internal command, Command is an external command (program).
    * Command is treated as an internal command only in Command Prompt and batch files running under Command Prompt environments.
  • Pipe/Redirection symbols
    |[Pipe] Passes the output of the left command as input to the right command.
    <[Input redirection] Passes specified file contents as input to the command.
    >[Output redirection] Writes the output of the command to the specified file.
    >>[Append redirection] Appends the output of the command to the specified file.
  • Special characters / Device file name etc.
    @Suppresses echo-back of commands in batch files.
    :Defines a label in batch files.
    ;Used to write comments in Config.sys file.
    %Used to retrieve values of environment variables and batch program parameters.
    !Used for the delayed environment variable expansion.
    ^Treats the following character as a regular character. Or treats multiple lines as one-line command line.
    &Executes two or more commands in a row.
    ||Used to execute the another command when the command fails.
    &&Used to execute the another command when the command succeeds.
    ( )Treats multiple commands like one command.
    CONA device file of ‘console’.
    NULA device file of ‘an empty file’
    AUXA device file used to communicate with the device through the default serial port.
    COMnA device file used to communicate with the device through the serial port corresponding to the specified number.
    PRNA device file used to communicate with the device (printer) through the default parallel port.
    LPTnA device file used to communicate with the device through the parallel port corresponding to the specified number.