How to wait in a batch script

Community Tested

Why choose wikiHow?
When you see the green checkmark on a wikiHow article, you know that the article has received careful review. In this case, we tested the instructions on our own devices and confirmed that the instructions worked.

How to Delay a Batch File

This wikiHow teaches you how to prevent a batch file from running immediately after being opened. There are a few different commands you can use to delay your batch file depending on your needs. Keep in mind that you should have a fairly firm grasp on how to write a batch file before attempting to delay one.


  1. Open Start .Click the Windows logo in the bottom-left corner of the screen.
    • If you have an existing batch file you'd like to delay, right-click the file, then clickEditto open the file in Notepad. You can then skip the next two steps.
  2. Open Notepad.Type innotepadto search for Notepad, then clickNotepadat the top of the Start window.
  3. Create your batch file.Often starting with [email protected] offcommand, enter your batch file's text as needed.
  4. Determine how you want to delay your file.There are three main commands you can use to delay a batch file:
    • PAUSE— Causes the batch file to pause until a standard key (e.g., the spacebar) is pressed.
    • TIMEOUT— Prompts the batch file to wait for a specified number of seconds (or a key press) before proceeding.
    • PING— Pauses the batch file until the file receives a return ping from a specified computer address. This usually results in only a small delay if you ping a working address.
  5. Select a place to delay your file.You can delay a batch file at any point in the code (save for after the "Exit" command if you used one). Scroll down until you find the point at which you want to delay the file, then create a space between the code before the delay point and the code after.
  6. Type in your command.Depending on your preferred command, do one of the following:
    • PAUSE— Typepauseinto the line. You don't need to add anything else here.
    • TIMEOUT— Typetimeout timewhere "time" is replaced by the number of seconds to delay. For example, typing intimeout 30will delay your batch file for 30 seconds.
      • If you want to prevent people from skipping the delay with a keypress, type intimeout time /nobreak(where "time" is the number of seconds to wait).
    • PING— Type inping addresswhere "address" is the IP address for a computer or website you want to PING.
  7. Save your document as a batch file.If you haven't yet saved your document as a batch file, do the following:
    • ClickFile, then clickSave As....
    • Type in your file's name followed by.bat(e.g., "My Batch File" would become "My Batch File.bat").
    • Click the "Save as type" drop-down box, then clickAll Files.
    • Select a save location, then clickSave.

Community Q&A

  • Question
    How do I not get a message when I use timeout?
    wikiHow Contributor
    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?
    wikiHow Contributor
    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.
    wikiHow Contributor
    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?
    wikiHow Contributor
    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 delete the message for ping?
    wikiHow Contributor
    Community Answer
    You should have: ping [a fake ip] Add >nul Now it should look like this: ping [a fake ip] >nul
  • Question
    How do I get rid of a warning message for a time out?
    wikiHow Contributor
    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.
Unanswered Questions
  • What can I do if I need to loop a ping but it keeps repeating itself instantly?
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
  • You can run your batch file on any Windows computer by double-clicking it.
  • The "PAUSE" command is best used in situations where you're relying on a user to trigger the next section of the batch file, while the "TIMEOUT" command is suited to situations in which you want to allow the file to run automatically.


  • The formerly used "SLEEP" command does not work on Windows 10.
  • Batch files won't run on Mac computers.

Related wikiHows

Sources and Citations

Article Info


In other languages:

Español: , Italiano: , Português: , Русский: , Deutsch: , Français: , Bahasa Indonesia: , Nederlands: , ไทย: , العربية: , 中文: 

Thanks to all authors for creating a page that has been read 917,219 times.
Is this article up to date?
Tested By:
wikiHow Technology Team

of How to Delay a Batch File was reviewed on July 11, 2019.

How helpful is this?
Views: 917,219

Nangah Shikari

Jun 6, 2019

"This is great. The ping one, especially. I was working on crashing computers and I worked out that it takes 128windows to crash an 8GB RAM, but with this command it takes 64 only."

Richard Weeber

Mar 14, 2019

"Someone asked me to use the SLEEP command, which didn't work on my version of Windows. I've now discovered theTIMEOUT command, which was a big help."

Paul Andrews

Mar 1, 2019

"I just needed a way to program a delay, and this article told me that the SLEEP command had been replaced by theTIMEOUT command. Problem solved."


Jul 20, 2019

"This helped me so much, thank you. I tried one, then realized it wouldn't work for me, so I tried the next one andit worked great!"
Rated this article:


Sep 7, 2019

"I searched for milliseconds .BAT delay. Couldn't get it from any site, this was really helpful."

Farhan R.

Nov 12, 2019

"Amazing! Provided me with multiple ways to accomplish my task. Very helpful."

Renato Giacomelli

Aug 11, 2019

"I have found help to find a way to delay a string command in a batch file."

Vijaysanthosh K.

Nov 17, 2019

"It was helpful to see various options explained with screenshot scrapped."

Gigi McNauton

Aug 4, 2019

"I really love coding games in Batch, so this helped so much. "
Rated this article:


Jul 11, 2019

"The ping command helped. Thank you very much!"


Jul 27, 2019

"It got to the point, and was useful for me."


Jul 23, 2019

"The pause, timeout and ping were helpful.

Video: Batch Scripting - 9 - Custom Pause and Animation

How to Delay a Batch File
How to Delay a Batch File images

2019 year
2019 year - How to Delay a Batch File pictures

How to Delay a Batch File forecast
How to Delay a Batch File recommend photo

How to Delay a Batch File photo
How to Delay a Batch File pictures

How to Delay a Batch File How to Delay a Batch File new photo
How to Delay a Batch File new foto

pictures How to Delay a Batch File
foto How to Delay a Batch File

Watch How to Delay a Batch File video
Watch How to Delay a Batch File video

Communication on this topic: How to Delay a Batch File, how-to-delay-a-batch-file/
Discussion on this topic: How to Delay a Batch File, how-to-delay-a-batch-file/ , how-to-delay-a-batch-file/

Related News

The 13 Best Bulges of 2019
N this Tuesday Feb. 27, 2012 photo, Kathy Deady holds up a tube of Naloxone Hydrochloride, also known as Narcan, in her Quincy, Mass., home. AP PhotoCharles Krupa
How to Set Up a Red Lion Pax2D
6 Tips to Help You Save Money on BeautyProducts
How to Prepare for a Catastrophe
Why Some Women Have So Much More Trouble Getting Pregnant Than Others
How Much of Your Tax Refund Should You Really Spend
Taking the tube to work is about to get a whole lot worse
The Best Pieces On The High Street This Season
7 Surprisingly Healthy Mexican Recipes for Cinco de Mayo
Merriam-Webster Announces Feminism Is the 2019 Word of the Year
Is White Rice Healthy 7 Ways It Can Help You Out

Date: 07.12.2018, 03:28 / Views: 61593