Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Sleep and Timeout?

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?

like image 959
YoloJoe Avatar asked Jan 21 '15 00:01

YoloJoe


1 Answers

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.

like image 138
rojo Avatar answered Sep 30 '22 17:09

rojo