I have tried the various solutions given here on an XP machine, since the idea was to have a batch file that would run on a variety of machines, and so I picked the XP machine as the environment likely to be the least capable.
This seemed to give a three second delay as expected. One ping attempt lasting a specified 3 seconds. This took around 10 seconds not 5.
My explanation is that there are 5 ping attempts, each about a second apart, making 4 seconds. And each ping attempt probably lasted around a second making an estimated 9 seconds in total. I tried the above too, after reading that comments could be added to BAT files by using two consecutive colons. However the software returned almost instantly. Putting the comment on its own line before the ping worked fine. My explanation is that there are 5 ping attempts each lasting 5 seconds, but there is about a 1 second time delay between ping attempts: there is after all little reason to expect a different result if you ping again immediately and it is better to give a network a little time to recover from whatever problem it has had.
Edit: stolen from another post ,.. RFC says the IP address I have modified the text above accordingly! I made this. It is working and show time left in seconds.
If you want to use it, add to a batch file:. Listing of wait. An improvement of the code proposed by the user Aacini, It has resolution of hundredths of a second and does not fail when the time reaches , You can use VBScript , for example, file myscript. I use the following method entirely based on Windows XP capabilities to do a delay in a batch file:. You may also insert the day in the calculation so the method also works when the delay interval pass over midnight.
Download the Sleep. It can be done with two simple lines in a batch file: write a temporary. If you have an appropriate version of Windows and the Windows Server Resource Kit Tools , it includes a sleep command for batch programs. EDIT: You should also be away that if the machine isn't connected to a network say a portable that your using in the subway , the ping trick doesn't really work anymore.
That is, unless you tell it to only wait for 1 second before timing out. I wrote a powerbasic program wait. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 12 years, 2 months ago. Active 1 year, 6 months ago. Viewed 2. Peter Mortensen Refs: SS64 , Rob van der Woude. There is timeout command that waits for seconds.
In case if millisecond sleep is needed, powershell's Start-Sleep can be used. To sleep 50ms in cmd: powershell Start-Sleep -m 50 — Pavel P. Pavel: You can also misuse a ping to a non-existent host to sleep for milliseconds. A good summary of the various techniques to halt a batch file process: robvanderwoude. Show 2 more comments. Active Oldest Votes. Please note however thanks Dan!
Evgeniy Berezovsky Timeout is poorly implemented. If you do a "timeout 1", it will wait until the "next second," which could occur in. Try doing "timeout 1" a few times and observe the difference in delay. For 5 seconds or more, it may not be a big deal, but for a 1 second delay it works poorly.
Show 20 more comments. One hack is to mis use the ping command: ping This IP address is guaranteed to always resolve, be reachable, and immediately respond to pings. There is a 1s delay between each ping, so for a 5s delay you need to send 6 pings.
MultiplyByZer0 4, 3 3 gold badges 29 29 silver badges 46 46 bronze badges. Martin Martin This doesn't work well for me could be a networking issue?
When I try the above command without the pipe to nul I immediately get a "Destination host unreachable" from the gateway server and the ping command exits straight away. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question.
Asked 12 years, 3 months ago. Active 1 year, 5 months ago. Viewed k times. Improve this question. Cegorach Cegorach 1 1 gold badge 6 6 silver badges 9 9 bronze badges. Or you could use powershell: stackoverflow.
Wish a sleep. Simple c exe 40k or so! Like this one sleepcmd. Windows batch: sleep — phuclv. By submitting your email, you agree to the Terms of Use and Privacy Policy. For instance, using the following on the command prompt will pause the terminal for 10 seconds unless you press a key:. Use Google Fonts in Word. Use FaceTime on Android Signal vs. Customize the Taskbar in Windows What Is svchost.
Best Smartwatches. Best Gaming Laptops. Best Smart Displays. Best Home Security Systems. Best External Solid State Drives. Best Portable Chargers. Best Phone Chargers. I know this is an old post but I hope I can help others in the future.
The script bellow will take each address from the iplist. Each result will then be outputted to the result. Now due to how the pathping command works, the only way to "stop" it is by terminating the CMD window it's self.
For each address we summon one pathping window and one taskkill window. The taskill window will use the Task PID of the pathping window and wait 20 seconds before terminating it. Mean while, the core batch file will wait 40 seconds for all the files to wright and close. It will then combine all the data into the result. How are we doing? Please help us improve Stack Overflow. Take our short survey.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
0コメント