I'm not saying windows batch programming is stupid, but if you want to insert a delay, your options are:
* commands only added in later versions of windows
* commands included in the SDK, but not the OS
* ping yourself N times
* pipe a comment into a DOS command asking a question
* commands only added in later versions of windows
* commands included in the SDK, but not the OS
* ping yourself N times
* pipe a comment into a DOS command asking a question
the PING one is amusing: if you tell PING to exit after 5 tries, it will run for about 4 seconds.
So you can do "ping localhost -n 6 >NUL" to get an about-5-seconds pause.
So you can do "ping localhost -n 6 >NUL" to get an about-5-seconds pause.
the problem is that this will fail if your computer doesn't have TCP/IP
and yeah, you can have a windows install without TCP/IP.
and yeah, you can have a windows install without TCP/IP.
so the other option is the DOS choice command, which presents the user with a simple question, defaulting to Y/N.
But it has an option to select one choice after a timeout...
so you can do "CHOICE /C:AB /T:A,10 >NUL" to get a 10 second pause
But it has an option to select one choice after a timeout...
so you can do "CHOICE /C:AB /T:A,10 >NUL" to get a 10 second pause
except of the problem of maybe the user is pushing something of the keyboard around then, and that'll ether make it end early or take longer
so you need to send nothing to it.
What's the easiest way to do that, in batch?
PIPE A COMMENT IN!
so you need to send nothing to it.
What's the easiest way to do that, in batch?
PIPE A COMMENT IN!
so to make a comment in a batch file you do
REM COMMENT HERE
but "REM" is effectively acting as a command that does nothing... so if you do REM | FOOBAR you're actually setting up a command pipe that sends nothing to FOOBAR as input.
REM COMMENT HERE
but "REM" is effectively acting as a command that does nothing... so if you do REM | FOOBAR you're actually setting up a command pipe that sends nothing to FOOBAR as input.
thus the correct way to do a choice-timeout is:
REM | CHOICE /C:AB /T:A,10 >NUL
REM | CHOICE /C:AB /T:A,10 >NUL
fun fact: the originally suggested way to do this was to do "REM | CHOICE /T:N,10 >NUL" which works on english installs of windows, but not some other languages.
Because the default for choice is to ask you a Yes/No question, or Y/N.
Because the default for choice is to ask you a Yes/No question, or Y/N.
Maybe you're on a Korean version of windows and the default options are Y/A instead, so it's going to error out when it sees you told it to default to "No" after 10 seconds