Q&A for How to Delay a Batch File

Return to Full Article

Search
Add New Question
  • Question
    How do I not get a message when I use timeout?
    Community Answer
    Add the >nul qualifier, like this: timeout /t 120 >nul. This causes a 2 minute delay with no output to the screen.
  • Question
    What if the sleep command doesn't work?
    Community Answer
    If the sleep command doesn't work, use timeout instead.
  • Question
    What if I want to wait less than one second? I can't just use a dot or a comma.
    Community Answer
    You can use the ping command. This command, if used with a non-existent IP address, will try to talk to a non-existent computer and give up after a specified number of milliseconds. Just multiply the number of seconds by 1000, and you're good to go.
  • Question
    What can I do if the PING command skips?
    Community Answer
    Make sure that you are using an invalid IP address. Also, remove '>nul' from the end and see what it outputs -- this might tell you why it skips.
  • Question
    How do I check if a folder is created?
    David Langr
    Community Answer
    In this case, you can use "Parenthesis": @echo off IF EXIST "C:\Folder" ( echo Folder exists! ) ELSE ( Echo Folder does not exist! ) pause > nul
  • Question
    How do I get rid of a warning message for a time out?
    Community Answer
    To get rid of the warning message for a timeout, out >nul at the end of the line, and it will hide the warning.
  • Question
    How do I delete the message for ping?
    Community Answer
    You should have: ping [a fake ip] Add >nul Now it should look like this: ping [a fake ip] >nul
  • Question
    Can time out be used under an IF condition?
    Community Answer
    Yes, example: IF "String" == "String" (timeout 10 echo "String is equal to other string").
  • Question
    What do i do if the TIMEOUT command skips?
    Community Answer
    You might have pressed a key before or during the timeout part. You should use timeout /t /nobreak.
  • Question
    How to remove the "Waiting for seconds, press ctrl+c to quit" prompt?
    TutorialGod4
    Community Answer
    Adding >nul to the end of the line should work. "timeout /nul" is the command you want from this answer.
  • Question
    Can you use a 0.5 second time out?
    Arrogance
    Top Answerer
    Not using the timeout command. You would need to supply your own program with a better granularity, or invoke PowerShell with the Start-Sleep command. "powershell -command "Start-Sleep -m 500".
  • Question
    Is there a way to change the measurement of time for timeout? For example, milliseconds, minutes.
    Arrogance
    Top Answerer
    The timeout command only supports seconds as an input. You can use up to 100000 seconds, which is approximately 1,666 minutes or 27 hours, so it isn't really a problem that it doesn't accept minutes or hours.
Ask a Question

      Return to Full Article