There are 2 more practical ways to delay processing a batch file in Windows without delaying the sleep function like Linux:
1, using the sleep function of wscirpt, precision 0.001 seconds
Create a VBS delay file, and then call it in a batch file, using the WScript sleep function to achieve the effect of sleep.
Actual combat:
1) Create file Sleep.vbs:
echo Wscript.Sleep > Sleep.vbs
Sleep.vbs content is as follows:
Wscript.Sleep 5000.
2) Called in the batch file, create the sample file Test.bat, as follows:
sc stop Oracleoradb10g_home1tnslistener
Wscript Sleep.vbs
SC start Oracleoradb10g_home1tnslistener
2, the use of ping timing function, the accuracy of 1 seconds
Actual combat: Create the sample file Test2.bat, as follows:
sc stop Oracleoradb10g_home1tnslistener
Ping-n 3 127.0.0.1>nul
SC start Oracleoradb10g_home1tnslistener
Description: 3 is the number of ping packets sent, which can be used as a delay of seconds, which requires a few seconds to be set.
The >nul avoids screen output and inputs the output to an empty device because no results are required and only its timing function is used.
3, there are two ways to achieve sleep function
One is through the continuous reading system time, to achieve a certain value when the exit to realize the sleep function, but the operation should be CPU large, not recommended.
The other is a German friend of the practice, directly using the Debug method to generate a timer program, the method may damage the stability of the system, or easily implanted virus (using other people's code), nor recommended.
Windows command Line (batch) file delay (sleep) method