How to simulate Sleep for batch processing in Windows

Source: Internet
Author: User

There is no formal Sleep for calling after a good batch processing. Sometimes, it is really boring.

1. Method 1:

Ping 1.1.1.1 to simulate

It is difficult to find an answer (called an answer because it is labeled as answer) from stackoverflow:
Ping 1.1.1.1-n 1-w 60000> nul
This indicates that sleep is performed for 60 seconds.

Is that true? It is based on the assumption that 1.1.1.1 will never be pinged by the target machine. However, I encountered a strange incident. On a test machine, I can ping the server directly:

Pinging 1.1.1.1 with 32 bytes of data:
Reply from 1.1.1.1: bytes = 32 time <1 ms TTL = 60
Reply from 1.1.1.1: bytes = 32 time <1 ms TTL = 60
Reply from 1.1.1.1: bytes = 32 time = 6 ms TTL = 60
Reply from 1.1.1.1: bytes = 32 time <1 ms TTL = 60


Ping statistics for 1.1.1.1:
Packets: Sent = 4, stored ED = 4, Lost = 0 (0% loss ),
Approximate round trip times in milli-seconds:
Minimum = 0 ms, Maximum = 6 ms, Average = 1 ms

Therefore, this method is unreliable.


2. ping is still used for simulation,

See the following bat:

@echo offecho "emulate sleep......"call :wait_ext1 60echo "60 seconds waited...."goto :eof:wait_ext1@ping 127.0.0.1 -n 2 -w 1000 > nul@ping 127.0.0.1 -n %1% -w 1000> nul

This indicates that sleep takes about 60 seconds.

Of course, you can also rename the wait_ext1 part to a separate batch for calling.


3. It seems that 2003 has another resource kitpackage downloaded, with sleep.exe on its side.

(Why not release it ?)
Http://malektips.com/xp_dos_0002.html


Sometimes I hate Windows for batch processing.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.