Windows command line BAT batch delay Sleep method (batch delay) _dos/bat

Source: Internet
Author: User
Tags sleep sleep function

Windows batch files do not have a Linux-like sleep function for latency processing, there are 2 more practical ways to implement latency:

1, the use of wscirpt sleep function, precision 0.001 seconds

Create a VBS delay file, and then invoke 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 5000 > Sleep.vbs

Sleep.vbs contents are as follows:

Wscript.Sleep 5000.

2 in a batch file, create the sample file Test.bat, which reads as follows:

Copy Code code as follows:

sc stop Oracleoradb10g_home1tnslistener
Wscript Sleep.vbs
SC start Oracleoradb10g_home1tnslistener

2, the use of ping timing function, precision 1 seconds

Combat: Create the sample file Test2.bat, which reads as follows:

Copy Code code as follows:

sc stop Oracleoradb10g_home1tnslistener
Ping-n 3 127.0.0.1>nul
SC start Oracleoradb10g_home1tnslistener

Note: 3 for Ping packet send number, can be used as a delay of seconds, need to delay a few seconds to set a few.

>nul avoids the screen output and enters the output into the empty device because no result is required and only its timing function is used.

3, there are two ways to achieve sleep function

One is through continuous reading system time, comparison, to achieve a certain value to quit the realization of sleep function, but this operation should consume CPU larger, not recommended.

The other is a German man's approach, directly using the Debug method to generate a timer program, this method may damage the stability of the system, or easily implanted virus (using other people's code), also not recommended.

Copy Code code as follows:

echo Q | Debug>nul
echo Bj@jzh ' 0x-'/ppppppa (DE (DM) ("Do" ("Dh" (Ls () (LX) (lezrr]eeeuyrx2dx=>sleep.com
Echo 0dxfp,0xx.t0p,=xtgsb4o@$? Piyu Wwx0gwuy wv;ovbx2gv0exgiuht6>>sleep.com
echo t}{z~~ @GwkBG @oekcut ' ~} @MqqBsy sehb~_phxr? @zAB ' lrpeyodt@cj?>>sleep.com
Echo pky_jn@qekpet@ij?jysjn@rekpet@jj?jygjn@sekkjtlgunw?p@pjirz>>sleep.com
Echo Lfvaurq? Oyltq@@?~qcool~rdu@?au?@{qoq?@}ikunwpe~fpeqfwh? Vkk>>sleep.com
echo _gsqocvh{ojeoseiqrma@knefb?p?? Mcjnne~b? M?? Qhetlbgbphexh@e=>>sleep.com
Echo Esogwtlblk?sfu '? Ldod@@k@xo? Suuda?_fkj@n? Kd@? Ua?? O}hcqoq?? R>>sleep.com
Echo _oqol? Cla? Ceu?_fu? Uaq? UBD? LOC? ORO? Uol? UOD? OOI? UGL? Lor@yuo?>>sleep.com
Echo Dsmsqswdor[bqaq? Lua?_l_ounusclooulooduo? Uoe@owh? Uoq? Djtsdm>>sleep.com
Echo Qtqrk@kcmsulkpcloouloofuo?hwdtqostdbntqrrdsdftlnbtm ' lthkct>>sleep.com
echo @dmTkRQSoddTT ~? K? OCOQP?o?? Gds?wow? Pgatachqvnntqv_w? A?it\eh>>sleep.com
echo {zpqpkgk? Jbs? Fqokoh{t?jpvp@iqbdfan? Ohrol? Kj?? Pd~an? Ohrod? G>>sleep.com
echo Q?? Pgt~b?? Oc~?ipo? T?~u?p~cuo0x>>sleep.com
Sleep.com>sleep.exe
Del sleep.com

The above code uses batch processing. Use Sleep.exe 10000 time unit is milliseconds

4. Download Sleep.exe files from Cloud Habitat community

Http://www.jb51.net/softs/2466.html

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.