Suspends processing of a batch program and displays a message that prompts the user to press any key to continue.
PAUSE /?
PAUSE
none.
TIMEOUT - Delay that allows the user to
press a key and continue immediately.
Equivalent Linux BASH commands:
read - read a line from standard input.
The operating system displays the message in response to the PAUSE command:
Press any key to continue . . .
To suppress the message:
PAUSE >nul
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.
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
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.
none.