{"id":266,"date":"2006-06-23T16:05:05","date_gmt":"2006-06-23T21:05:05","guid":{"rendered":"http:\/\/192.168.33.66\/wp\/?p=266"},"modified":"2006-06-23T16:05:05","modified_gmt":"2006-06-23T21:05:05","slug":"dos-batch-sleep","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=266","title":{"rendered":"dos batch sleep"},"content":{"rendered":"<p>slow down a batch file<br \/>\n<!--more--><\/p>\n<p>\n&#8220;Gustav Medler&#8221; wrote in message <br \/>\n> Hello, <br \/>\n> is there a program anywhere which stopps executing of batch files for 1 <br \/>\n> or 2 seconds without need to touch the keyboard? <\/p>\n<p>> PAUSE requires a keyboard stroke&#8230;. batch needs user&#8217;s attention&#8230;. <\/p>\n<p>There are four main options for delays in Batch scripts: <\/p>\n<p>1) Use the time-delay built into CHOICE command <\/p>\n<p>\nThis can be used for delays from 1-99 seconds. For example, <br \/>\nthis command line delays 10 seconds before resuming. Change <br \/>\nthe 10 to a number from 1-99 for other delay periods. <\/p>\n<p>\n:: Delay script execution for 10 seconds <br \/>\nREM | choice \/c:delay \/td,10>NUL <\/p>\n<p>\n2) Use the built-in delay mechanism of the PING command. <\/p>\n<p>\nAssuming you have Microsoft TCP\/IP installed, you can PING <br \/>\nthe LocalHost and obtain delays in this way. With PING, you <br \/>\nneed to specify a number equal to 1 second longer than you <br \/>\nwant the delay to be. Unlike CHOICE delays, PING delays are <br \/>\nnot limited to 99 seconds, however. <\/p>\n<p>\n:: Delay script execution for 10 (= 11-1) seconds <br \/>\nping -n 11 127.0.0.1>NUL <\/p>\n<p>\n3) The free Microsoft SLEEP.EXE command <\/p>\n<p>\nMicrosoft provide a free SLEEP utility as part of the free <br \/>\nWindows 98 Resource Kit Batch tools. With the SLEEP.EXE <br \/>\nexecutable placed in the system path, for example in the folder <br \/>\nC:\\WINDOWS\\COMMAND, the delay syntax is simple: <\/p>\n<p>\n:: Delay script execution for 10 seconds <br \/>\nsleep 10 <\/p>\n<p>\nDownload Microsoft SLEEP.EXE Batch tool free from: <br \/>\nftp:\/\/ftp.microsoft.com\/Services\/TechNet\/samples\/ps\/win98\/reskit\/scrp&#8230; <br \/>\nand click on the filename SLEEP.EXE <\/p>\n<p>\n4) Using the START command <br \/>\nSometimes, a delay is wanted merely to allow a GUI process to finish. <br \/>\nIn these cases the START command is useful. The command line: <\/p>\n<p>\nstart \/w &#8220;C:\\program files\\SomeProgram.exe&#8221; <\/p>\n<p>\nwill run the program SomeProgram.exe in a separate process and \/w=Wait <br \/>\nfor it to complete before continuing. Use &#8220;quotes&#8221; around any file <br \/>\nspecification that contains [Space]s. For brief help with START type: <br \/>\nstart \/? <\/p>\n<p>\n====== <\/p>\n<p>\nNotes: <br \/>\n(a) Although the CHOICE delay method is useful to know, CHOICE <br \/>\ndelays are very CPU intensive. Typically, CHOICE uses up all <br \/>\nthe spare CPU time available during the delay (although it isn&#8217;t <br \/>\nperforming any useful task). The PING version of the delay uses <br \/>\ntypically under 0.5% of CPU capacity, and will often record a <br \/>\nnegligible CPU usage on fast systems. So for other than trivial <br \/>\ndelays, PING is most definitely to be preferred. Delays using <br \/>\nthe SLEEP command use negligible CPU time. <\/p>\n<p>\n(b) To study CPU usage of tasks such as the CHOICE, PING, <br \/>\nor SLEEP delay techniques, you can use the free Microsoft <br \/>\nprocess viewer WinTop: <\/p>\n<p>\nTo install WinTop, get the free download from page: <br \/>\nhttp:\/\/www.microsoft.com\/windows95\/downloads\/default.asp <br \/>\nscroll down the page, and locate the item: Windows 95 Kernel Toys <br \/>\nClick on that and click the DownLoad Now button on the next <br \/>\npage. Run the packed executable: w95krnltoys.exe, in a temporary <br \/>\nfolder, and when it unpacks, right click on WinTop.inf, and click <br \/>\ninstall. After a few moments, you can remove the contents of the <br \/>\ntemporary folder. Place a link to C:\\Windows\\Wintop.exe on the <br \/>\ndesktop to run WinTop. To terminate a process with WinTop, right <br \/>\nclick on the process, click Properties, Priority tab, click <br \/>\nTerminate Process Now. WinTop has a small database of &#8220;essential&#8221; <br \/>\nOS components (they show with a small cog icon) which it won&#8217;t <br \/>\nterminate (for example mmtask). The Win95 Kernel Toys package is <br \/>\nsuitable for Win98 (and ME as far as I am aware). <\/p>\n<p>\n(c) Windows 95\/98\/ME START command features: <br \/>\nSTART is an external command: executable file START.EXE <br \/>\n(For brief help with START, type the command: start \/? ) <\/p>\n<p>\n(i) start \/w Program.EXE \/Any \/Switches <br \/>\nThis runs Program.EXE in a separate process thread, and Waits(\/w) <br \/>\nfor it to complete before continuing. If Program.EXE returns an <br \/>\ninformative ERRORLEVEL, START (with \/w) returns that ERRORLEVEL <br \/>\nto the parent Batch file. <\/p>\n<p>\n(ii) start Program.EXE <br \/>\nAs \/w, but doesn&#8217;t wait for Program.EXE to complete, nor does it <br \/>\nreturn an informative ERRORLEVEL from Program.EXE <\/p>\n<p>\nWindow control for the STARTed process is provided through the <br \/>\n\/m(=run in Minimized window) \/max(=run in MAXimised window) and <br \/>\n\/r(=run in Restored window). <\/p>\n<p>\n(iii) start DATAFILE.EXT <br \/>\nOpens DATAFILE.EXT in the application registered in the CLASSES_ROOT <br \/>\nsection of the Registry to handle files of that type. For example: <br \/>\n  (a) start http:\/\/www.website.com\/index.htm <br \/>\n      opens that page in your default Web browser. <br \/>\n  (b) start textfile.txt <br \/>\n      opens that file in your default Text editor (usually NotePad). <\/p>\n<p>\n(iv) Native ERRORLEVELs from START <br \/>\nstart \/?>NUL <br \/>\nThis command line returns ERRORLEVEL 255 if used in the Windows GUI <br \/>\n(protected mode), and ERRORLEVEL 1 if used in real-mode. <\/p>\n<p>\n(v) Separate START command line parameters with [Space]s <br \/>\nWhen using START, always use [Space]s to separate its command line <br \/>\nelements, so for example, although, without START: <br \/>\nchoice\/c:yn <br \/>\nis valid syntax, with START, you must insert a [Space] before \/c: <br \/>\nstart choice \/c:yn <\/p>\n<p>\nNote: Windows 2000 <br \/>\nIn Windows 2000 and similar OSes, START is an internal command. <br \/>\nUse start \/? in Windows 2000 for details of the extensive extra <br \/>\nfeatures available (including process priority control). <\/p>\n<p>\n&#8212; <br \/>\n(pp) William Allen <\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>slow down a batch file<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":0,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}