So I have created a text adventure batch game, but after testing it on my home computer, none of the sleep commands work. My home PC is running Win 8.1 and the Laptop used to creating the game is running Win7. I don't know if this is the reason why the 'Sleep' function don't work..
But could anyone tell me the difference between sleep
and timeout
? And why isn't the sleep commands working anymore?
Sleep
is a Windows Scripting Host command (like JScript or VBScript). It's not really a cmd-interpreted batch thing.
Timeout
is like a pause
that auto continues after a specified time or on keypress (unless the /nobreak
switch is used).
There's also waitfor
, which pauses for X seconds or until a signal is received from another computer or window.
timeout
and waitfor
are included with Windows 7 and newer. For compatibility with earlier versions of Windows, traditionally, ping
is used to simulate a pause like this:
ping -n 6 0.0.0.0 >NUL
... will pause for 5 seconds. (-n 6
means ping 6 times. The first ping response is instant, so N+1 is needed to pause N seconds.)
Some people also use choice /t
to pause. See the How to sleep for 5 seconds in Windows Command Prompt related page if you'd like. There may be a reference to a utility or resource kit there you've installed that makes Sleep work on your Win 7 laptop, which has not been installed on your 8.1 desktop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With