Windows Command Line (batch processing) file delay (sleep) method, batch processing sleep
In Windows, the next batch processing file does not have the same Sleep function as in Linux for latency processing. Here there are two more practical methods to achieve latency:
1. Use the sleep function of WScirpt, with an accuracy of 0.001 seconds
Create a vbs delayed file, call it in the batch file, and use the sleep function of WScript to implement the sleep effect.
Practice:
1) Create the file sleep. vbs:
Echo WScript. sleep 5000> sleep. vbs
The content of sleep. vbs is as follows:
WScript. sleep 5000.
2) Create the sample file test. bat called in the batch processing file. The content is as follows:
SC stop OracleOraDb10g_home1TNSListener
Wscript sleep. vbs
SC start OracleOraDb10g_home1TNSListener
2. Use the ping timing function. The precision is 1 second.
Practice: Create the example file test2.bat with the following content:
SC stop OracleOraDb10g_home1TNSListener
Ping-n 3 127.0.0.1> nul
SC start OracleOraDb10g_home1TNSListener
Note: 3 is the number of sent ping packets, which can be used as the delay seconds. You need to set the delay seconds.
> Nul avoids screen output and sends the output to an empty device. Because no result is required, it only uses its timing function.
3. There are two ways to implement the Sleep function.
One is to exit the sleep function when the system time is continuously read and compared. However, this operation consumes a large amount of CPU, which is not recommended.
Another is a German Buddy's practice. A Timer Program is directly generated using the debug method, which may damage the system stability or be prone to virus implantation (using others' code ), it is not recommended.