PAUSE - Pause

Maintained on
Table of Contents

When you run a batch file by double-clicking it, the command prompt window may close the moment the script finishes, so you cannot read the result.

The PAUSE command solves this. It pauses the batch file and waits until the user presses any key.

Basic Usage

PAUSE takes no options.

Syntax
PAUSE

When executed, it displays the following message and waits for a key press:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>pause
Press any key to continue …
C:\users\user>

After you press a key, processing resumes from the next line. Keys that do not produce a character on their own, such as Shift or Ctrl, do not count as a key press.

Example in a Batch File

result_check.cmd
@echo off
setlocal

echo Listing files.
echo.
dir /b *.txt
echo.
echo Done.

pause
endlocal

Placing PAUSE at the end of the batch file lets you check the result before the window closes.

Customizing the Message

The message of PAUSE itself cannot be changed. Instead, display your own message with echo and hide the output of PAUSE with >nul.

custom_message.cmd
@echo off
echo Done. Press any key to exit.
pause >nul
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>custom_message.cmd
Done. Press any key to exit.
C:\users\user>
Tip

pause >nul is handy when you want to show your own message and only wait for a key press.

Common Uses

Stopping Midway for Debugging

Inserting PAUSE in the middle of a batch file lets you check progress step by step.

debug.cmd
@echo off
setlocal

echo Step 1: Copying file...
copy "data.txt" "backup\data.txt" >nul 2>&1
echo Done (error code: %ERRORLEVEL%)
pause

echo Step 2: Deleting old files...
del "temp\*.tmp" >nul 2>&1
echo Done (error code: %ERRORLEVEL%)
pause

echo All steps completed.
endlocal

Giving the User a Chance to Cancel

confirm.cmd
@echo off
echo Warning: all files in the temp folder will be deleted.
echo Press any key to continue, or press Ctrl+C to cancel.
pause >nul
del /q "temp\*.*"
echo Deletion completed.
PAUSE vs. TIMEOUT

PAUSE waits indefinitely until a key is pressed, whereas the TIMEOUT command waits for a specified number of seconds (and can be interrupted by a key press). For automated processing, TIMEOUT is more suitable.

Do not use it in unattended runs

PAUSE keeps waiting for a key press. If it runs under Task Scheduler or another unattended environment, the process never ends. Remove PAUSE from batch files that run unattended.

When the Window Closes Immediately

A batch file started by double-clicking closes its window as soon as the last line finishes, so even error messages vanish before you can read them.

  • Add pause as the last line: you can read the result after both success and failure.
  • Run it from Command Prompt: type the file name (for example result_check.cmd) in an already open window, and the output stays on screen.
  • Start it with cmd /k: set a shortcut target to cmd /k "C:\scripts\result_check.cmd" and the window stays open after the script ends.

Things to Keep in Mind

  • Pressing Ctrl + C interrupts the batch file even while PAUSE is waiting (if asked “Terminate batch job (Y/N)?”, enter Y).
  • If you already run the batch file from an open command prompt, the window does not close after it ends, so a final PAUSE is unnecessary. It is useful when the file is launched by double-clicking.
  • timeout /t -1 also waits for a key press. However, if input is redirected (for example timeout /t -1 < file.txt), it fails with the error “Input redirection is not supported”.

Summary

PurposeSyntax
Basic pausepause
Hide the messagepause >nul

Quiz

Practice Problem

How do you hide the default PAUSE message (“Press any key to continue …”)?

Choose one answer.

  1. Write pause >nul
  2. Write pause /q
  3. Write pause /silent
#Command Prompt #Batch File #PAUSE #Command