I am trying to make a Batch file, and part of it calls for a timeout command for 15 seconds to be called. This is that part of the code...
@echo off
timeout 15
echo The script is waiting to run...
pause
And the following is displayed...
Waiting for 15 seconds, press any key to continue...
The script is waiting to run...
pause
But what I am trying to do is make the message below the timeout line display in place of the timeout message. Is there any way that this can be done?
I think that this should work for you:
@echo off
echo The script is waiting to run...
timeout 15 > nul
pause
Change the order of operations. Print your message first, then do the timeout. It's considered bad form to hide the message from timeout, but redirecting to NUL can work when appropriate. Fifteen seconds isn't pushing it too much, but twenty or more, you need to let the user know they have a safe escape route and you need to deal with the fact that they can do so, whether or not you suppress its output.
I would add that Ctrl-C or Ctrl-Brk are always just a pair of keystrokes away if the user gets impatient, and always lead to even worse user experiences than an extra line in the output of your script.
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