Originally posted by htysm at 2007-1-21 04:19 PM:
DOS命令这么丰富,居然没有延迟命令,还要依靠第三方程序。
我不同意这个观点:
ping的消息发送间隔,时间精度为1秒,使用平台为Win9x/WinNT系列。
需要你的Windows系统中正常安装了网卡的TCP/IP协议,有两种方案:
(1) 利用ping两次发送消息之间的间隔时间。ping在发送多个消息时,在得到上一次消息的回应后,它会再等待1秒的时间才发送下一次消息,而这个回应时间因机型、系统和网络配置而不同,其中IP地址尤其关键,只有本地的回送地址 127.0.0.1 因为是立即回应所以才是相对恒定的,其他地址大多会产生显著的差异。此种方法要等待更大的时间,是指定发送的消息数为等待的时间加一,因为第一个消息是不等待的,IP 地址必须是 127.0.0.1 。其等待2秒的程序如下:
::根据植树原则,n后的数字为暂停秒数加一
ping -n 3 127.0.0.1>nul
(2) 利用ping的最大等待时间。ping向0.0.0.1发送一次“网际消息控制协议 (ICMP)”回响请求消息,因为 0.0.0.1 是个无法响应 ping 请求的IP地址,所以默认情况下,ping会等待一定的最大响应时间——4秒后便停止等待,而-w可以改变这个每发送一次消息所等待的最大响应时间。而如果将 IP 地址改为立即响应的127.0.0.1或其他响应时间很短的IP ,那 -w 便失去了作用,因为每次发送等待时间都不会达到最大的响应时间,此时延时会缩短。此种方法要等待更大的时间,可以直接使用 -w 指定,但是需要减去 500 毫秒(原因尚未知),而且 IP 地址必须是不响应请求的地址。其等待2秒的程序如下:
ping -n 2 -w 500 0.0.0.1>nul
echo Wscript.Sleep Wscript.Arguments(0) * 1000 >c:\delay.vbs
start /w c:\delay.vbs 15 --------------建15秒的延时
Originally posted by htysm at 2007-1-21 04:19 PM:
There are so many DOS commands, but there is no delay command, and third-party programs are still required.
I don't agree with this view:
The message sending interval of ping has a time precision of 1 second and is used on the Windows 9x/WinNT series platforms.
Your Windows system needs to have the TCP/IP protocol of the network card normally installed. There are two schemes:
(1) Use the interval time between two message sends of ping. When ping sends multiple messages, after getting the response of the previous message, it will wait for 1 second before sending the next message. The response time varies depending on the model, system, and network configuration. Among them, the IP address 127.0.0.1 is especially crucial because it responds immediately, so it is relatively constant. Most other addresses will have significant differences. This method requires waiting a longer time. The number of messages to send is one more than the waiting time because the first message does not wait. The IP address must be 127.0.0.1. The program to wait for 2 seconds is as follows:
:: According to the planting tree principle, the number after n is one more than the pause seconds
ping -n 3 127.0.0.1>nul
(2) Use the maximum waiting time of ping. ping sends an "Internet Control Message Protocol (ICMP)" echo request message to 0.0.0.1. Because 0.0.0.1 is an IP address that cannot respond to ping requests, by default, ping will wait for a certain maximum response time - it stops waiting after 4 seconds, and -w can change this maximum response time for each message send. And if the IP address is changed to 127.0.0.1 or other IP addresses with very short response times that respond immediately, then -w loses its effect because the waiting time for each send will not reach the maximum response time, and the delay will be shortened at this time. This method requires waiting a longer time. You can directly use -w to specify, but you need to subtract 500 milliseconds (the reason is not known), and the IP address must be an address that does not respond to requests. The program to wait for 2 seconds is as follows:
ping -n 2 -w 500 0.0.0.1>nul
echo Wscript.Sleep Wscript.Arguments(0) * 1000 >c:\delay.vbs
start /w c:\delay.vbs 15 --------------Create a 15-second delay