How to make a batch file wait for fractions of a second?

magnus167 picture magnus167 · Jun 5, 2015 · Viewed 16.3k times · Source

I want to make a batch file wait for 0.5 or 0.25 seconds.
I have already tried timeout /t 0.5 but it is not working.

It is something like:
@echo off color a cls :top echo %random% timeout /t 0.5 echo %random% goto top

Answer

MichaelS picture MichaelS · Jun 5, 2015

Try this: ping 127.0.0.1 -n 1 -w 500> nul 500 is the time in ms.

EDIT:

As rojo posted in the comments this won't work as expected for 250ms:

ping used this way pauses a minimum of 500ms. Using any value lower than 500 still results in a half second pause