用 timeout.exe 让脚本暂停 N 秒
用 Windows 内置的 timeout 命令在 CMD 或批处理脚本中定时等待,可按键跳过。
运行 timeout /t 10 /nobreak 等待 10 秒;/nobreak 表示忽略按键、等满计时。
01命令
命令
$ timeout /t 10 /nobreak02作用说明
timeout /t <秒数> 会倒计时,默认按任意键可跳过等待;/nobreak 则忽略按键(仅 Ctrl+C 可中断)。它在交互式 CMD 和批处理中可用,但在非交互环境(任务计划程序脚本、PowerShell 管道中)会报 'ERROR: Input redirection is not supported',此时应改用 PowerShell 的 Start-Sleep。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- timeout - SS64依据: Reference for timeout including the /nobreak and /nobreak behaviors and caveats in piped contexts.
- timeout依据: Documents timeout /t with /nobreak and the ignore-keyboard-input flag.
最后验证: 2026-09-17 · 分类: 系统与设置