Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 305 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to wait in a batch script?

#1
I am trying to write a batch script and trying to wait 10 seconds between 2 function calls. The command:

sleep 10

Does not make the batch file wait for 10 seconds.

I am running Windows XP.

**Note:** This is not a complete duplicate of [Sleeping in a batch file](

[To see links please register here]

) as the other question is about also about python, while this is about windows batch files.
Reply

#2
You'd better ping *127.0.0.1*. Windows ping pauses for one second between pings so you if you want to sleep for 10 seconds, use

ping -n 11 127.0.0.1 > nul

This way you don't need to worry about unexpected early returns (say, there's no default route and the 123.45.67.89 is instantly known to be unreachable.)
Reply

#3
I actually found the right command to use.. its called timeout:

[To see links please register here]

Reply

#4
I used this

:top
cls
type G:\empty.txt
type I:\empty.txt
timeout /T 500
goto top

Reply

#5
What about:

@echo off
set wait=%1
echo waiting %wait% s
echo wscript.sleep %wait%000 > wait.vbs
wscript.exe wait.vbs
del wait.vbs

Reply

#6
Well, does `sleep` even exist on your Windows XP box? According to this post:

[To see links please register here]

`sleep` isn't available on Windows XP, and you have to download the [Windows 2003 Resource Kit][1] in order to get it.

Chakrit's answer gives you another way to pause, too.

Try running `sleep 10` from a command prompt.

[1]:

[To see links please register here]

Reply

#7
You can ping an address that doesn't exist and specify the desired timeout:

ping 192.0.2.2 -n 1 -w 10000 > nul

And since the address does not exist, it'll wait 10,000 ms (10 seconds) and return.

* The `-w 10000` part specifies the desired timeout in milliseconds.
* The `-n 1` part tells ping that it should only try _once_ (normally it'd try 4 times).
* The `> nul` part is appended so the ping command doesn't output anything to screen.

You can easily make a sleep command yourself by creating a sleep.bat somewhere in your PATH and using the above technique:

rem SLEEP.BAT - sleeps by the supplied number of seconds

@ping 192.0.2.2 -n 1 -w %1000 > nul

---

**NOTE (September 2020):** The 192.0.2.x address is reserved as per [RFC 3330](

[To see links please register here]

) so it definitely will not exist in the real world. Quoting from the spec:

> 192.0.2.0/24 - This block is assigned as "TEST-NET" for use in
> documentation and example code. It is often used in conjunction with
> domain names example.com or example.net in vendor and protocol
> documentation. Addresses within this block should not appear on the
> public Internet.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through