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:
  • 542 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sleeping in a batch file

#11
You can get fancy by putting the PAUSE message in the title bar:

@ECHO off
SET TITLETEXT=Sleep
TITLE %TITLETEXT%
CALL :sleep 5
GOTO :END
:: Function Section
:sleep ARG
ECHO Pausing...
FOR /l %%a in (%~1,-1,1) DO (TITLE Script %TITLETEXT% -- time left^
%%as&PING.exe -n 2 -w 1000 127.1>NUL)
EXIT /B 0
:: End of script
:END
pause
::this is EOF
Reply

#12
I disagree with the answers I found here.

I use the following method entirely based on Windows XP capabilities to do a delay in a batch file:

DELAY.BAT:

@ECHO OFF
REM DELAY seconds

REM GET ENDING SECOND
FOR /F "TOKENS=1-3 DELIMS=:." %%A IN ("%TIME%") DO SET /A H=%%A, M=1%%B%%100, S=1%%C%%100, ENDING=(H*60+M)*60+S+%1

REM WAIT FOR SUCH A SECOND
:WAIT
FOR /F "TOKENS=1-3 DELIMS=:." %%A IN ("%TIME%") DO SET /A H=%%A, M=1%%B%%100, S=1%%C%%100, CURRENT=(H*60+M)*60+S
IF %CURRENT% LSS %ENDING% GOTO WAIT

You may also insert the day in the calculation so the method also works when the delay interval pass over midnight.
Reply

#13
I faced a similar problem, but I just knocked up a very short C++ console application to do the same thing. Just run *MySleep.exe 1000* - perhaps easier than downloading/installing the whole resource kit.

<!-- language: c -->

#include <tchar.h>
#include <stdio.h>
#include "Windows.h"

int _tmain(int argc, _TCHAR* argv[])
{
if (argc == 2)
{
_tprintf(_T("Sleeping for %s ms\n"), argv[1]);
Sleep(_tstoi(argv[1]));
}
else
{
_tprintf(_T("Wrong number of arguments.\n"));
}
return 0;
}
Reply

#14
`SLEEP.exe` is included in most Resource Kits e.g. [The Windows Server 2003 Resource Kit][1] which can be installed on Windows XP too.

Usage: sleep time-to-sleep-in-seconds
sleep [-m] time-to-sleep-in-milliseconds
sleep [-c] commited-memory ratio (1%-100%)


[1]:

[To see links please register here]

Reply

#15
If you've got [PowerShell][1] on your system, you can just execute this command:

powershell -command "Start-Sleep -s 1"


----------
Edit: from [my answer on a similar thread][2], people raised an issue where the amount of time powershell takes to start is significant compared to how long you're trying to wait for. If the accuracy of the wait time is important (ie a second or two extra delay is not acceptable), you can use this approach:

powershell -command "$sleepUntil = [DateTime]::Parse('%date% %time%').AddSeconds(5); $sleepDuration = $sleepUntil.Subtract((get-date)).TotalMilliseconds; start-sleep -m $sleepDuration"

This takes the time when the windows command was issued, and the powershell script sleeps until 5 seconds after that time. So as long as powershell takes less time to start than your sleep duration, this approach will work (it's around 600ms on my machine).

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#16
The pathping.exe can sleep less than second.

@echo off
setlocal EnableDelayedExpansion
echo !TIME! & pathping localhost -n -q 1 -p %~1 2>&1 > nul & echo !TIME!
.

> sleep 10
17:01:33,57
17:01:33,60

> sleep 20
17:03:56,54
17:03:56,58

> sleep 50
17:04:30,80
17:04:30,87

> sleep 100
17:07:06,12
17:07:06,25

> sleep 200
17:07:08,42
17:07:08,64

> sleep 500
17:07:11,05
17:07:11,57

> sleep 800
17:07:18,98
17:07:19,81

> sleep 1000
17:07:22,61
17:07:23,62

> sleep 1500
17:07:27,55
17:07:29,06
Reply

#17
The [Resource Kit][1] has always included this. At least since Windows 2000.

Also, the Cygwin package has a `sleep` - plop that into your PATH and include the `cygwin.dll` (or whatever it's called) and way to go!

[1]:

[To see links please register here]

Reply

#18
Even more lightweight than the Python solution is a Perl
one-liner.

To sleep for seven seconds put this in the BAT script:

perl -e "sleep 7"

This solution only provides a resolution of one second.

If you need higher resolution then use the Time::HiRes
module from CPAN. It provides `usleep()` which sleeps in
microseconds and `nanosleep()` which sleeps in nanoseconds
(both functions takes only integer arguments). See the
Stack Overflow question *[How do I sleep for a millisecond in Perl?][1]* for further details.

I have used [ActivePerl][2] for many years. It is very easy to
install.

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#19
The [`timeout`][1] command is available from Windows Vista onwards:

c:\> timeout /?

TIMEOUT [/T] timeout [/NOBREAK]

Description:
This utility accepts a timeout parameter to wait for the specified
time period (in seconds) or until any key is pressed. It also
accepts a parameter to ignore the key press.

Parameter List:
/T timeout Specifies the number of seconds to wait.
Valid range is -1 to 99999 seconds.

/NOBREAK Ignore key presses and wait specified time.

/? Displays this help message.

NOTE: A timeout value of -1 means to wait indefinitely for a key press.

Examples:
TIMEOUT /?
TIMEOUT /T 10
TIMEOUT /T 300 /NOBREAK
TIMEOUT /T -1

Note: It does not work with input redirection - trivial example:

C:\>echo 1 | timeout /t 1 /nobreak
ERROR: Input redirection is not supported, exiting the process immediately.

[1]:

[To see links please register here]

Reply

#20
I am impressed with this one:

[To see links please register here]


choice /n /c y /d y /t 5 > NUL

Technically, you're telling the `choice` command to accept only y. It defaults to y, to do so in 5 seconds, to draw no prompt, and to dump anything it does say to NUL (like null terminal on Linux).

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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