timeout - Wait

Maintained on

In a batch file, you sometimes need to wait for a certain amount of time, like sleep or wait in other programming languages.

For example, you may want to launch an application with the start command and wait a few seconds for it to be ready before moving on to the next step.

To wait for a specified time in the command prompt or a batch file, use the timeout command. This article explains how to use it, from basic usage to options, with sample code.

Basic Usage of the timeout Command

The usage of the timeout command is as follows:

timeout /t <seconds> [/nobreak]

The /t option is required. If you run the command without it, you will get the following error:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>
timeout
ERROR: Invalid syntax.
Type “TIMEOUT /?” for usage.

Specify the number of seconds to wait for /t in the range from -1 to 99999.

For example, to wait for 10 seconds, use the following command:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>
timeout /t 10
Waiting for 10 seconds, press a key to continue …
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

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

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

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

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

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

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

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

The timeout command does not always wait for the full time.

The correct behavior is “wait for the specified time if the user does nothing.” Even with timeout /t 10, if the user presses a key, the wait ends and the next command runs.

To disable this behavior, use the /nobreak option.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>
timeout /t 10 /nobreak
Waiting for 10 seconds, press CTRL+C to quit …

With /nobreak, no key other than Ctrl + C can interrupt the wait.

Pressing Ctrl + C interrupts the batch file itself (you are asked “Terminate batch job (Y/N)?”).

Examples of the timeout Command

Waiting Indefinitely Until the User Takes Action

By specifying -1 for the /t option, you wait indefinitely until the user presses a key.

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

This is also useful at the end of a batch file to keep the window open so that the user can read the output.

Adding a Wait Time Between Commands in a Batch File

To add a wait time between commands, write the following:

@echo off
setlocal

echo Process 1

timeout /t 10

echo Process 2

endlocal

Since /nobreak is not specified, the wait ends when the user presses a key and Process 2 runs.

Always Waiting the Full Time Between Commands

To prevent key presses from interrupting the wait, specify the /nobreak option.

@echo off
setlocal

echo Process 1

timeout /t 10 /nobreak

echo Process 2

endlocal

When the timeout Command Does Not Work

The timeout command may fail with the following error when input redirection is used (for example, timeout /t 10 < input.txt) or in environments where standard input is unavailable:

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>
ERROR: Input redirection is not supported, exiting the process immediately.

In such cases, you can wait by using the reply time of a ping to 127.0.0.1. Specify the number of seconds to wait plus 1 for -n.

ping 127.0.0.1 -n 11 > nul

The above waits for about 10 seconds.

Confirmation Test

Practice Problem

Which command waits indefinitely until the user takes some action?

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