Pause

Index

The PAUSE command suspends processing of a batch program and displays a prompt to press any key to continue.

Syntax:

PAUSE

Notes:

  1. PAUSE displays the following message:

     
    Press any key to continue . . .

  2. Typically, PAUSE is used just before some irrevocable operation are about to take place - eg: file deletions, or disk formats. In such a case, PAUSE would often be preceded by an ECHO statement on the lines of:
    ECHO All files on C: drive will be erased.
    ECHO Press Ctrl-C to stop or
    PAUSE

    which would display as:

     
    All files on C: drive will be erased.
    Press Ctrl-C to stop or
    Press any key to continue . . .

  3. Any text following PAUSE is ignored. If ECHO is on, it will be displayed; if ECHO is off it isn't. Thus:
    ECHO On
    Pause awhile and be sure understand what you are about to do.

    will display as:

     
    Pause awhile and be sure understand what you are about to do.
    Press any key to continue . . .

  4. The prompt "Press any key to continue . . ." can be supressed by redirecting the output to NUL:
    PAUSE > NUL

  5. The point of the PAUSE command is to allow a certain minimum level of interaction with the user. However, as Larry Weiss points out below, it will react to input from a file by redirection.

    Given a zero-length file named FLAG, if you execute PAUSE < FLAG the command.com session under Windows 98 in an MSDOS-Prompt box will seem to hangup. But, if you open another MSDOS-Prompt and run anything that writes into that FLAG file, then that will trigger the first session's PAUSE command to complete. Seems a very simple way to get some coordination between batch files running in separate MSDOS-Prompt sessions. I don't have a practical application for this yet, but it seems an interesting trick.

    Presumably, this effect would also work with other sources of redirected input such as COM1, etc. (?)

File Details:

Internal


This page last revised:
June 3, 2000