on-internet
← Community

How to gobble any buffered STDIN before "pause" in a batch file?

Stack Overflow ·

A fair number of our "automate a group of installers" .bat files end with something like: :success ECHO Success! (as far as I can tell) ECHO. ECHO. ECHO Press any key to reboot... ECHO. ECHO. PAUSE >NUL shutdown -r EXIT /b If the prior commands have taken a while, there's a good chance the user has accidentally hit a key well before we reach the :success label. Since STDIN seems to be buffered, this will cause the PAUSE to be dismissed instantly. What I'd rather have is something like: GOBBLE_STDIN_SOMEHOW PAUSE >NUL shutdown -r How would I "flush" STDIN, consuming anything that was there, but

Comments

Sign in or sign up to comment and upvote.

No comments yet.