PAUSE - Pause

Maintained on

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.

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.

Example in a Batch File

@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.

@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>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

チェック

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.

@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

@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.

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.

Summary

PurposeSyntax
Basic pausepause
Hide the messagepause >nul

Quiz

Practice Problem

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

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #PAUSE #Command