|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
   『楼 主』:
批处理延时命令——sleep(我的鸡肋收藏)
使用 LLM 解释/回答一下
我初涉dos时,曾下大力气寻找sleep.exe,幸运的找到了。在网上看到过很多关于批处理延时的方法,本论坛里更是精华,但很少有人用sleep命令(非vbs),只好压在箱底。
近日看到有人推荐sleep.exe(是以毫秒为单位的),勾起了我的兴趣,厚着脸皮拿出我的鸡肋收藏,希望有人可以用的上。它是以秒为单位的,即:sleep 10 就表示延时10秒。
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.
此帖被 +11 点积分 点击查看详情 评分人:【 redtek 】 | 分数: +1 | 时间:2006-11-22 03:21 | 评分人:【 wanyu555 】 | 分数: +2 | 时间:2007-5-30 01:44 | 评分人:【 JasonMing 】 | 分数: +2 | 时间:2007-8-2 00:23 | 评分人:【 tashaxin 】 | 分数: +2 | 时间:2007-12-30 12:42 | 评分人:【 htxiang 】 | 分数: +1 | 时间:2008-1-19 21:48 | 评分人:【 】 | 分数: +1 | 时间:2009-4-14 08:54 | 评分人:【 】 | 分数: +1 | 时间:2010-7-12 14:48 | 评分人:【 】 | 分数: +1 | 时间:2010-12-9 11:58 |
|
附件
1: sleep.rar (2006-11-22 03:09, 13.73 KiB, 下载附件所需积分 1 点
,下载次数: 3770)
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-22 03:09 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
顶啊,原来这么多好东东都被私藏了
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'>" |
|
2006-11-22 04:41 |
|
|
tao0610
高级用户
    朦胧的世界
积分 579
发帖 218
注册 2006-10-24
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
私藏果然不同凡响!
Last edited by tao0610 on 2006-11-22 at 06:18 AM ]
The private collection is indeed extraordinary!
Last edited by tao0610 on 2006-11-22 at 06:18 AM ]
此帖被 +1 点积分 点击查看详情 评分人:【 】 | 分数: +1 | 时间:2009-4-14 08:55 |
|
|

认识自己,降伏自己,改变自己,才能改变别人! |
|
2006-11-22 05:42 |
|
|
balinger
中级用户
  
积分 356
发帖 115
注册 2004-7-27
状态 离线
|
|
2006-11-22 05:44 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
 『第 5 楼』:
使用 LLM 解释/回答一下
俺这个是毫秒级的,不知道能不能在纯DOS下使用,只有1k^_^
sleep 1000 一秒
This is millisecond level. I don't know if it can be used under pure DOS. Only 1k ^_^
sleep 1000 for one second
附件
1: sleep.rar (2006-11-22 06:11, 453 bytes, 下载附件所需积分 1 点
,下载次数: 618)
|
|
2006-11-22 06:11 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
多谢楼主提供的小工具,收藏~:)
Thanks to the LZ for providing the small tool, bookmarked~ : )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-22 07:16 |
|
|
zgren1979
初级用户
 
积分 52
发帖 24
注册 2006-11-16
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
收藏下!支持,我也要追上大家步伐
Save it! Support, I also want to keep up with everyone's pace
|
|
2006-11-22 09:35 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
呵呵,下载下来试了下,好象不支持中文代码页哦。同时也发现一个奇怪的现象。大家在命令行试试这个:
echo %time% && ping 127.1 -n 10 >nul && echo %time%
或者
echo %time% && sleep 10 && echo %time%
有没有发现怎么不对劲的?
这并不在我们的意料之中,按理来说应该两次时间不一样,可是上面的命令却推翻了这个想象。费解。。。。
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....
|
|
2006-11-22 10:20 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
 『第 9 楼』:
使用 LLM 解释/回答一下
因为
echo %time% && ping 127.1 -n 10 >nul && echo %time%
执行前%time%已经被先转换成当前时间才执行的。
例子。
set a=1
echo %a%&&set a=2&&echo %a%
实际运行的是
echo 1&&set a=2&&echo 1
启动延缓环境变量扩展后就是你所想要的结果。
set a=1
echo %a%&&set a=2&&echo !a!
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!
此帖被 +5 点积分 点击查看详情 评分人:【 redtek 】 | 分数: +3 | 时间:2006-11-22 21:45 | 评分人:【 weapfe 】 | 分数: +1 | 时间:2006-12-3 05:47 | 评分人:【 p1509101 】 | 分数: +1 | 时间:2008-4-3 16:55 |
|
|

QQ:366840202
http://chenall.net |
|
2006-11-22 11:07 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
呵呵,多谢指定,貌似同一行命令里面,变量的值即时被扩展了。呵呵。
做成两行就不会出现类似的问题了。
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.
|
|
2006-11-22 11:13 |
|
|
120144008
新手上路

积分 9
发帖 4
注册 2006-10-29
状态 离线
|
|
2006-11-22 13:23 |
|
|
aspirer
初级用户
 
积分 72
发帖 35
注册 2006-11-13
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
赞 楼主奉献!
收藏之,备用!
Like the LZ for sharing!
Collect it for future use!
|
|
2006-11-23 05:47 |
|
|
hxuan999
中级用户
   DOS之日
积分 337
发帖 161
注册 2006-11-4
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
好东西,收藏.
|

for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul |
|
2006-11-24 05:39 |
|
|
weikiss
初级用户
  Q群:IT永恒国度367763 ...
积分 44
发帖 21
注册 2006-11-12
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
我一般用wait这个,用法:WAIT 10(单位秒)
I usually use wait this way: WAIT 10 (unit: seconds)
|

Q群:IT永恒国度3677635 高明人上门维修电脑群28387927[维修软件总部]fsgm.ys168.com
|
|
2006-11-24 06:11 |
|
|
hxuan999
中级用户
   DOS之日
积分 337
发帖 161
注册 2006-11-4
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
发一个上WAIT来呀.
Post a WAIT come on.
|

for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul |
|
2006-11-25 04:37 |
|