Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
784 views
in Technique[技术] by (71.8m points)

batch-file - 如何在批处理文件/ cmd中休眠五秒钟[重复](How to sleep for five seconds in a batch file/cmd [duplicate])

This question already has an answer here:

(这个问题在这里已有答案:)

Windows's Snipping tool can capture the screen, but sometimes I want to capture the screen after five seconds, such as taking an image being displayed by the webcam.

(Windows的Snipping工具可以捕获屏幕,但有时我想在五秒钟后捕获屏幕,例如拍摄网络摄像头显示的图像。)

(Run the script and smile at the camera, for example.)

((例如,运行脚本并对相机微笑。))

How do I sleep for 5 seconds in a batch file?

(如何在批处理文件中睡5秒?)

  ask by 太極者無極而生 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm very surprised no one has mentioned:

(没有人提到我,我感到非常惊讶:)

C:> timeout 5

NB Please note however (thanks Dan!) that timeout 5 means:

(NB请注意(感谢Dan!) timeout 5意味着:)

Sleep anywhere between 4 and 5 seconds

(睡眠时间在4到5秒之间)

This can be verified empirically by putting the following into a batch file, running it repeatedly and calculating the time differences between the first and second echo s:

(这可以通过将以下内容放入批处理文件中,重复运行并计算第一个和第二个echo之间的时间差来凭经验验证:)

@echo off
echo %time%
timeout 5 > NUL
echo %time%

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...