1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Windowsのbatで一定秒数待つ処理(スリープ的なこと)

Last updated at Posted at 2023-02-04

概要

スタートアップに『特定のアプリケーションを起動させるbat』を設置している。
だが、時々アプリケーションの起動が失敗する時がある。
どうやら PC起動と同時(間髪入れず) アプリケーションを起動しているのが良くなさそう。

bat内で一定秒数待つ処理をいれたい。

やり方

rem 20分待つ。(60秒×20=1200)
timeout /t 1200 /nobreak >nul

まず timeout /t 秒数 で指定秒数待つ処理を実装。

だが、 timeout /t 秒数 だけだと途中でユーザーがキー入力した際、待つ処理が中断されてしまう。
なので /nobreak を付けてキー入力中断を防止。

また、下記のような『※秒待っています。…』の表示を出さないようにする為、 >nul を付けている。
image.png

sleepというコマンドは存在しない

image.png

参考サイトさん

バージョン

Windows 10 Pro 22H2 OSビルド 19045.2546

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?