You are not logged in.

#1 19 Mar 2021 19:16

Manna5
Member
From: Cracow, Poland
Registered: 18 Mar 2021
Posts: 16
Website

Is there a way to delay batch file for exact amout of seconds on Win7?

I know that there is the timeout command, but it is available only on Windows 10. I can also delay my batch file using ping like this:

ping localhost -n 5 >nul

But it will depend on the computer speed. Is there any more sure method that works on Windows 7?

Last edited by Manna5 (19 Mar 2021 19:19)

Offline

#2 19 Mar 2021 22:35

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Is there a way to delay batch file for exact amout of seconds on Win7?

Windows 7 is no longer safe
https://securityboulevard.com/2020/04/n … -in-sight/

How to upgrade from Windows 7 to Windows 10 for free
https://www.theverge.com/2020/1/14/2106 … 10-free-os

Offline

#3 20 Mar 2021 10:48

Manna5
Member
From: Cracow, Poland
Registered: 18 Mar 2021
Posts: 16
Website

Re: Is there a way to delay batch file for exact amout of seconds on Win7?

Thanks, but I had Windows 10 and it was too glitchy for me, and I downgraded to Windows 7. Also, if I later publish my batch file, its users may have not got Windows 10.

Last edited by Manna5 (20 Mar 2021 10:52)

Offline

#4 20 Mar 2021 13:36

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Is there a way to delay batch file for exact amout of seconds on Win7?

As mentioned by Simon, Windows 7 is well out of support and thus I'd strongly caution against using it in any environment that is not entirely sandboxed from the web.

That said, here are some potential alternatives to `ping`, with caveats attached.

https://ss64.com/nt/timeout.html -- seems like it uses clock second boundaries, so a bad option if accuracy of the interval is of a concern to you as you imply.
https://ss64.com/nt/choice.html -- this would be a misuse, may not work in non-interactive scenarios; in interactive scenarios a user could press a key to hurry things along.
https://ss64.com/nt/waitfor.html -- another misuse, wait for a signal that never comes and timeout at the requested interval (I've never tried this one so it might not be suitable for some reason).

You're going to have to try these out for yourself to see if they address your accuracy concerns.

As for your objection to ping, I'm not sure how much of a variation you might be expecting based on computer speed, I'll defer to your knowledge of your environment on this.

If accuracy is your chief concern, and high processor usage is not an issue, you could write something in batch that inspects the clock repeatedly to wait for the desired amount of time to pass, but this would be a pretty nasty solution.

Last edited by bluesxman (23 Mar 2021 10:18)


cmd | *sh | ruby | chef

Offline

#5 22 Mar 2021 09:17

Try3
Member
Registered: 20 Jul 2019
Posts: 9

Re: Is there a way to delay batch file for exact amout of seconds on Win7?

"I know that there is the timeout command, but it is available only on Windows 10. ... Is there any more sure method that works on Windows 7?"

TimeOut is also available in Windows 7.

Whatever has made you think otherwise is incorrect.

Denis

Last edited by Try3 (22 Mar 2021 09:18)

Offline

#6 22 Mar 2021 14:32

Manna5
Member
From: Cracow, Poland
Registered: 18 Mar 2021
Posts: 16
Website

Re: Is there a way to delay batch file for exact amout of seconds on Win7?

Try3: Really, it works on 7. When it was not working, I was propably working on XP (I have got 2 computers).

Offline

Board footer

Powered by