Batch script - sleep in milliseconds


/ Published in: DOS Batch
Save to your folder(s)

In DOS/cmd batch scripts it is not possible to issue a SLEEP command for less than 1 second. This script allows you to use a single batch script to double as a jscript (double-execution) in order to accomplish a single script/command that can specify sleep in milliseconds.

Usage:

Save script as a filename (not sleep.bat) such as millisleep.bat and put it in your path.

From within another batch script invoke it and pass in the number of milliseconds to sleep: (example below will sleep 250 milliseconds, which is 1/4th of a second)

millisleep.bat 250


Copy this code and paste it in your HTML
  1. @set @junk=0 /* This line is ignored by both Batch and VBS Interpreters. This starts the Batch portion:
  2. @echo off
  3. cscript //nologo //e:jscript "%~f0" %~1
  4. goto :eof
  5.  
  6. Jscript part begins here */
  7. WSH.Sleep(WScript.Arguments.Item(0));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.