PAUSE

Pause the execution of a batch file.

Syntax
      PAUSE

Displays the message "Press any key to continue . . ."

Presssing Ctrl-C when this prompt appears will offer the option: Terminate batch job (Y/N)?
Pressing either y or Y will then end the batch script immediately.

To suppress the message:

PAUSE >nul

To display a different message:

Echo Are you sure? Press Ctrl-C to cancel.
PAUSE >nul

Execution of a batch script can also be paused by pressing CTRL-S (or the Pause|Break key) on the keyboard, this also works for pausing a single command such as a long DIR /s listing.
Pressing any key will resume the operation.

Pause is often used at the end of a script to give the user time to read some output text.
An alternative to this is to run the script using CMD /K:

START CMD /k C:\demo\yourscript.cmd

That will run the script and the window will remain open for any further input. The limitation is that this only acts like a PAUSE statement at the very end of a script.

PAUSE does not set or clear the Errorlevel.
PAUSE is an internal command.

“Advertising may be described as the science of arresting the human intelligence long enough to get money from it” - Stephen Leacock

Related commands

SLEEP - Wait for x seconds.
TIMEOUT - Delay that allows the user to press a key and continue immediately.
PowerShell: Pause
Equivalent bash command (Linux): read -p "press any key to continue" or ctrl-z & fg


 
Copyright © 1999-2024 SS64.com
Some rights reserved