批处理中的睡眠/等待命令

Ull*_*lan 9 sleep batch-file wait

我想在我的批处理文件中添加时间延迟.批处理文件将在backgorund上静默运行.请帮我.

小智 18

timeout 5

延迟

timeout 5 >nul

延迟而不要求你按任何键取消


fie*_*sey 5

你想使用超时。timeout 10 将休眠 10 秒

  • @HPFE455 - 只需将输出重定向到 nul:`>nul timeout 10` (3认同)

Its*_*inc 5

ping localhost -n (your time) >nul
Run Code Online (Sandbox Code Playgroud)

例子

@echo off
title Test
echo hi
ping localhost -n 3 >nul && :: will wait 3 seconds before going next command (it will not display)
echo bye! && :: still wont be any spaces (just below the hi command)
ping localhost -n 2 >nul && :: will wait 2 seconds before going to next command (it will not display)
@exit
Run Code Online (Sandbox Code Playgroud)