How to make counter in cmd?

Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,185
Found this page for you. - http://www.wikihow.com/Delay-a-Batch-File
  1. PAUSE
    1. Use the PAUSE command to make the program wait for the user. This will cause the computer to wait for any key to be pressed. The key will not be printed to the screen. If you want to delay for a specific amount of time, see one of the following methods.
    2. Place the PAUSE command where you want the program to wait. The user will be prompted to continue.
    3. Hide the PAUSE dialog. You can add >nul to the end of any command to send its output to the "Null Device" so it doesn't appear on the screen. Make sure you don't add >null to the end; that will create a new file called null and put the output there.
  2. TIMEOUT
    1. Use the TIMEOUT command to make the program wait a specified amount of time. The user can skip this waiting period, or you can apply a parameter that keeps the user from skipping.
      • TIMEOUT may not work with older systems. Try the deprecated SLEEP command if the TIMEOUT command isn't working.
    2. Place the TIMEOUT command where you want the program to wait. Add the flag /t followed by the number of seconds.
    3. Keep the user from skipping the break. Add the flag /nobreak to keep any input from skipping the delay.
      • The user can still end the program by pressing Ctrl + C (keyboard interrupt).
  3. SLEEP
    1. Use the SLEEP command to make the program wait the specified number of seconds. SLEEP is deprecated; if possible TIMEOUT should be used instead.
    2. Place the SLEEP command where you want to program to wait. Add the number of seconds you want it to wait after the SLEEP command. The SLEEP command cannot be interrupted by the user.
  4. PING
    1. Use the PING command to force the program to wait by sending a message to another computer and waiting for a reply. You must ping a non-valid IP address, otherwise a computer might actually reply, and the delay won't be long enough. You cannot ping a non-valid hostname, such as madeup.example.com otherwise error messages will be shown instead of a delay.
    2. Insert the PING command where you want the delay to occur. The -n 1 parameter adds a second ping to the original command. The wait between the two pings, designated by -w 30000, is the delay. The delay has to be entered as milliseconds. Putting >nul at the end will send the command's output to the "Null Device".
 
Joined
Mar 8, 2009
Messages
5,063
Reaction score
1,185
Ping has a designated length of time it will wait for a response. The length of time Ping will wait for a non-existent IP address to respond is how long you can make your command-line script wait.

You probably know as much about Ping as I do. I myself have only used ping a time or two, but never as a form of pausing. I have used pause mostly, sleep with counters, and I believe timeout once.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top