Home > Commands N-Z > Batch P

PAUSE


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Suspends processing of a batch program and displays a message that prompts the user to press any key to continue.


Syntax

PAUSE /?

PAUSE


Parameters

none.


Switches
/? (NTXP)
Displays help.

Related

TIMEOUT - Delay that allows the user to press a key and continue immediately.
Equivalent Linux BASH commands:
read - read a line from standard input.


Notes
Prompting the user to continue the program

The operating system displays the message in response to the PAUSE command:

    Press any key to continue . . .

Suppressing the message

To suppress the message:

    PAUSE >nul

Dividing a batch file into sections

If you press CTRL+C (^C) to stop a batch program, the operating system displays the message:

    Terminate batch job (Y/N)?

If you press Y (for yes) in response to this message, the batch program ends and control returns to the operating system. Therefore, you can insert the PAUSE command before a section of the batch file you may not want to process. While PAUSE suspends processing of the batch program, you can press CTRL+C (^C) and then Y to stop the batch program.


Communication between separate DOS sessions under Windows

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. - Larry Weiss


Examples

Suppose you want a batch program to prompt the user to change disks in one of the drives. To do this, you might create the file:

    @ECHO OFF
    :BEGIN
     COPY A:*.*
     ECHO Please put a new disk into drive A
     PAUSE
     GOTO BEGIN

In this example, all the files on the disk in drive A are copied to the current directory. After the displayed comment prompts you to place another disk in drive A, the PAUSE command suspends processing so that you can change disks and then press any key to resume processing. This particular batch program runs in an endless loop. The GOTO BEGIN command sends the command interpreter to the begin label of the batch file. To stop this batch program, press CTRL+C (^C) and then Y.


Errorlevels

none.


Availability
Internal
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
NT3.5 NT4 NT2000 NTXP NT2003