I am trying to write a batch script and trying to wait 10 seconds between 2 function calls. The command:
sleep 10
Does not make the batch file wait for 10 seconds.
I am running Windows XP.
Note: This is not a complete duplicate of Sleeping in a batch file as the other question is about also about python, while this is about windows batch files.
You can ping an address that doesn’t exist and specify the desired timeout:
And since the address does not exist, it’ll wait 10,000 ms (10 seconds) and return.
-w 10000part specifies the desired timeout in milliseconds.-n 1part tells ping that it should only try once (normally it’d try 4 times).> nulpart is appended so the ping command doesn’t output anything to screen.You can easily make a sleep command yourself by creating a sleep.bat somewhere in your PATH and using the above technique:
NOTE (September 2020): The 192.0.2.x address is reserved as per RFC 3330 so it definitely will not exist in the real world. Quoting from the spec: