mardi 13 mars 2018

How do I wait for a random amount of milliseconds in batch with the ping command?

set /a wait=%RANDOM% * 250 / 32768
echo %wait%
ping 1.1.1.1 -n 1 -w %wait% >nul
[execute code, then go back to the beginning]

That's my code, which is in a loop. It's supposed to wait for a random amount of milliseconds from 0 to 250, using the ping -w parameter. I used the echo to see if it was actually random each time. It was. However, the actual wait time was not. It kept executing the code at a steady rate, rather than the random amount I was looking for.




Aucun commentaire:

Enregistrer un commentaire