| 1. |
Solve : Is it possible to delay a batch file invisibly?? |
|
Answer» I know how to delay a batch file with "pause", "timeout" or "PING", but they all show words on the screen when delaying. I want to delay a batch file without any words being showed on the screen. Is this possible? I know how to delay a batch file with "pause", "timeout" or "ping", but they all show words on the screen when delaying. I don't THINK he's asking about hidden batch files. You can redirect the output of all these commands to NUL which just swallows the console output so that nothing shows on screen. E.g. PAUSE > NUL This can be handy with e.g. PAUSE because it means you can replace the standard message with one of your own. Example batch script below @echo off echo 1. Running PING hidden echo Approximately 5 second delay echo Starting PING. The time is %time% PING 127.0.0.1 -n 6 > nul echo Finished PING. The time is %time% echo. echo 2. Running PAUSE hidden echo Waiting for you to press a key... echo Starting PAUSE. The time is %time% pause > NUL echo Finished PAUSE. The time is %time% echo. Echo 3. Running TIMEOUT hidden echo Timeout 10 seconds or when key is pressed... echo Please Wait or press a key... echo Starting TIMEOUT. The time is %time% Timeout /T 10 > NUL echo Finished TIMEOUT. The time is %time% echo. Echo 4. Running TIMEOUT hidden again echo Timeout 10 seconds (keypress locked out) echo Please Wait... echo Starting TIMEOUT. The time is %time% Timeout /T 10 /NOBREAK > NUL echo Finished TIMEOUT. The time is %time% echo. Console output... 1. Running PING hidden Approximately 5 second delay Starting PING. The time is 7:42:07.44 Finished PING. The time is 7:42:12.48 2. Running PAUSE hidden Waiting for you to press a key... Starting PAUSE. The time is 7:42:12.49 Finished PAUSE. The time is 7:42:22.22 3. Running TIMEOUT hidden Timeout 10 seconds or when key is pressed... Please Wait or press a key... Starting TIMEOUT. The time is 7:42:22.23 Finished TIMEOUT. The time is 7:42:32.17 4. Running TIMEOUT hidden again Timeout 10 seconds (keypress locked out) Please Wait... Starting TIMEOUT. The time is 7:42:32.18 Finished TIMEOUT. The time is 7:42:42.11 timeout /t X >nul 2>&1 will wait for X seconds, allowing the user to break upon pressing any key. You can add /NOBREAK to disable this feature and only wait the specified NUMBER of seconds. The >nul will suppress any regular text and the 2>&1 will suppress any error messages. >nul cannot be removed without changing 2>&1 to 2>nul. Timeout is newly available on windows 7, so your scripts will not be backwards compatible.Quote from: Whitebeard1 on October 26, 2013, 10:21:04 PM I know how to delay a batch file with "pause", "timeout" or "ping", but they all show words on the screen when delaying. I want to delay a batch file without any words being showed on the screen. Is this possible? i guess your saying Code: [Select]@echo off ping localhost -n 6 > nul console output will be blank for 5 secs. -n 6 = 5 secs. Thanks for the reply guys. And Geek-9pm, I'm not trying to do a crime or anything, I was talking about pausing a batch file without printing out an annoying "press any key to continue"The replies were helpful. I like the >NUL command, very helpful in my batch file.Quote from: Whitebeard1 on October 27, 2013, 11:40:19 PM Thanks for the reply guys. And Geek-9pm, I'm not trying to do a crime or anything, I was talking about pausing a batch file without printing out an annoying "press any key to continue"Didn't mean to say you were. In the past, some have come here asked similar questions and then when the get what the want STRANGELY diaper and never return. BTW; There are versions of SLEEP.EXE that give no output. But the >NUL is just as good and gets the job done with tools at hand. |
|