China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 05:04
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch delay command - sleep (my chicken rib collection) View 42,595 Replies 317
Original Poster Posted 2006-11-22 03:09 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
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.
Recent Ratings for This Post ( 8 in total) Click for details
RaterScoreTime
redtek +1 2006-11-22 03:21
wanyu555 +2 2007-05-30 01:44
JasonMing +2 2007-08-02 00:23
tashaxin +2 2007-12-30 12:42
htxiang +1 2008-01-19 21:48
+1 2009-04-14 08:54
+1 2010-07-12 14:48
+1 2010-12-09 11:58
Attachments
sleep.rar (13.73 KiB, Credits to download 1 pts, Downloads: 3770)
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 2 Posted 2006-11-22 04:41 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Top, so many good things were originally hoarded privately

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 3 Posted 2006-11-22 05:42 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
The private collection is indeed extraordinary!

[ Last edited by tao0610 on 2006-11-22 at 06:18 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+1 2009-04-14 08:55

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 4 Posted 2006-11-22 05:44 ·  中国 福建 福州 连江县 电信
中级用户
★★
Credits 356
Posts 115
Joined 2004-07-27 00:00
21-year member
UID 29114
Gender Male
Status Offline
Accepted. Thank you!
Floor 5 Posted 2006-11-22 06:11 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
This is millisecond level. I don't know if it can be used under pure DOS. Only 1k ^_^

sleep 1000 for one second
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
redtek +1 2006-11-23 06:31
haiou327 +8 2008-08-02 16:02
Attachments
sleep.rar (453 bytes, Credits to download 1 pts, Downloads: 618)
Floor 6 Posted 2006-11-22 07:16 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Thanks to the LZ for providing the small tool, bookmarked~ : )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 7 Posted 2006-11-22 09:35 ·  中国 广东 电信
初级用户
Credits 52
Posts 24
Joined 2006-11-16 06:50
19-year member
UID 70653
Gender Male
Status Offline
Save it! Support, I also want to keep up with everyone's pace
Floor 8 Posted 2006-11-22 10:20 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

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....
Floor 9 Posted 2006-11-22 11:07 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
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.

set a=1
echo %a%&&set a=2&&echo %a%

Actually running is
echo 1&&set a=2&&echo 1
After starting delayed environment variable expansion, it is the result you want.

set a=1
echo %a%&&set a=2&&echo !a!
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
redtek +3 2006-11-22 21:45
weapfe +1 2006-12-03 05:47
p1509101 +1 2008-04-03 16:55
QQ:366840202
http://chenall.net
Floor 10 Posted 2006-11-22 11:13 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  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.
Floor 11 Posted 2006-11-22 13:23 ·  中国 北京 鹏博士BGP
新手上路
Credits 9
Posts 4
Joined 2006-10-29 14:58
19-year member
UID 68784
Gender Male
Status Offline
Floor 12 Posted 2006-11-23 05:47 ·  中国 江苏 苏州 电信
初级用户
Credits 72
Posts 35
Joined 2006-11-13 01:26
19-year member
UID 70380
Gender Male
Status Offline
Like the LZ for sharing!
Collect it for future use!
Floor 13 Posted 2006-11-24 05:39
中级用户
★★
DOS之日
Credits 337
Posts 161
Joined 2006-11-04 05:27
19-year member
UID 69523
Gender Male
Status Offline
for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul
Floor 14 Posted 2006-11-24 06:11 ·  中国 广东 佛山 电信
初级用户
Q群:IT永恒国度367763 ...
Credits 44
Posts 21
Joined 2006-11-12 14:26
19-year member
UID 70341
Gender Male
Status Offline
I usually use wait this way: WAIT 10 (unit: seconds)
Q群:IT永恒国度3677635 高明人上门维修电脑群28387927[维修软件总部]fsgm.ys168.com
Floor 15 Posted 2006-11-25 04:37
中级用户
★★
DOS之日
Credits 337
Posts 161
Joined 2006-11-04 05:27
19-year member
UID 69523
Gender Male
Status Offline
Post a WAIT come on.
for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul
1 2 3 22 Next ›
Forum Jump: