中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 12:06
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » Batch delay command - sleep (my chicken rib collection)
Printable Version  44,654 / 317
Floor1 ccwan Posted 2006-11-22 03:09
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
When I first ventured into DOS, I made great efforts to look for sleep.exe and fortunately found it. I have seen many methods for batch processing delays on the Internet, and there are even gems in this forum, but few people use the sleep command (non-vbs), so I had to keep it in my collection.
Recently, I saw someone recommending sleep.exe (which is in milliseconds), which aroused my interest. I had the cheek to take out my鸡肋 collection and hope someone can make use of it. It is in seconds, that is: sleep 10 means delaying for 10 seconds.

Attachments
sleep.rar (13.73 KiB)
Floor2 electronixtar Posted 2006-11-22 04:41
铂金会员 Posts 2,672 Credits 7,493
Top, so many good things were originally hoarded privately
Floor3 tao0610 Posted 2006-11-22 05:42
高级用户 Posts 218 Credits 579
The private collection is indeed extraordinary!

[ Last edited by tao0610 on 2006-11-22 at 06:18 AM ]
Floor4 balinger Posted 2006-11-22 05:44
中级用户 Posts 115 Credits 356
Accepted. Thank you!
Floor5 zh159 Posted 2006-11-22 06:11
金牌会员 Posts 1,467 Credits 3,687
This is millisecond level. I don't know if it can be used under pure DOS. Only 1k ^_^

sleep 1000 for one second

Attachments
sleep.rar (453 bytes)
Floor6 redtek Posted 2006-11-22 07:16
金牌会员 Posts 1,147 Credits 2,902
Thanks to the LZ for providing the small tool, bookmarked~ : )
Floor7 zgren1979 Posted 2006-11-22 09:35
初级用户 Posts 24 Credits 52
Save it! Support, I also want to keep up with everyone's pace
Floor8 lxmxn Posted 2006-11-22 10:20
版主 Posts 4,938 Credits 11,386

Hehe, I tried downloading it and it seems that it doesn't support the Chinese code page. At the same time, I found a strange phenomenon. Everyone, try this in the command line:

echo %time% && ping 127.1 -n 10 >nul && echo %time%

Or

echo %time% && sleep 10 && echo %time%

Did you find something wrong?
This is not what we expected. According to reason, the two times should be different, but the above command subverts this imagination. It's puzzling....
Floor9 chenall Posted 2006-11-22 11:07
银牌会员 Posts 469 Credits 1,276 From 福建泉州
Because
echo %time% && ping 127.1 -n 10 >nul && echo %time%
The %time% before execution has already been converted to the current time before execution.
Example.

Actually running is
echo 1&&set a=2&&echo 1
After starting delayed environment variable expansion, it is the result you want.
Floor10 lxmxn Posted 2006-11-22 11:13
版主 Posts 4,938 Credits 11,386

  Hehe, thanks for the specification. It seems that in the same line of command, the value of the variable is expanded immediately. Hehe.

  Doing it in two lines won't have similar problems.
Floor11 120144008 Posted 2006-11-22 13:23
新手上路 Posts 4 Credits 9
Floor12 aspirer Posted 2006-11-23 05:47
初级用户 Posts 35 Credits 72
Like the LZ for sharing!
Collect it for future use!
Floor13 hxuan999 Posted 2006-11-24 05:39
中级用户 Posts 161 Credits 337
Floor14 weikiss Posted 2006-11-24 06:11
初级用户 Posts 21 Credits 44
I usually use wait this way: WAIT 10 (unit: seconds)
Floor15 hxuan999 Posted 2006-11-25 04:37
中级用户 Posts 161 Credits 337
Post a WAIT come on.
1 2 3 422  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023