Windows XP Sleep Command

S

Steven Adams

Sorry couldn't find a windows XP group to post this to !.

Under a default Windows XP install there doesn't seem to be a sleep command
available at the command prompt ?
Has this been replaced or just removed.
I need to pause the execution of a script for a period of time in an
automated way.
any ideas ?

thanks,

Steve
 
M

Matthias Tacke

Steven Adams said:
Sorry couldn't find a windows XP group to post this to !.

Under a default Windows XP install there doesn't seem to be a sleep command
available at the command prompt ?
Has this been replaced or just removed.
I need to pause the execution of a script for a period of time in an
automated way.
any ideas ?
There is a sleep in w2k reskit which isn't free.

When networking/tcp installes use as an alternative:

ping -n xx 127.0.0.1 >NUL

where xx is the number of seconds to pause.
 
P

Paul R. Sadowski

As far as I know sleep has never been part of the standard OS but is in the
resource kit.

There are also freeware sleep.exe around the web.

Here's two methods without going to an additional prog.
--------------------------------------------------------------------------------
call sleep 10
:sleep
:: sleep for x number of seconds
ping -n %1 127.0.0.1 > NUL 2>&1
goto :EOF
--------------------------------------------------------------------------------
cscript sleep.vbs 10

where sleep.vbs is:
args = wScript.Arguments.Count
if args <> 1 then
wscript.Echo "usage: " & Wscript.ScriptName & " seconds to sleep" & _
vbCRLF & "Example: " & Wscript.ScriptName & " 10"
wscript.Quit
end if
wscript.sleep wscript.Arguments.Item(0) * 1000
--------------------------------------------------------------------------------
Problems:
firewalls could screwup ping either by disallowing it or by not being
configured for it and asking the user for what to do with it.

sleep.vbs is not accurate because it may take a couple of second to
initialize. So 10 second delay might be 12 or even 13. Also, anti-virus
programs can be set to block scripts and some people even change the
scripting associations.

But if you know the machine(s) then these might do, or not. Only you can
decide.
 
C

Clay Calvert

call sleep 10
:sleep
:: sleep for x number of seconds
ping -n %1 127.0.0.1 > NUL 2>&1
goto :EOF
Problems:
firewalls could screwup ping either by disallowing it or by not being
configured for it and asking the user for what to do with it.

Pinging 127.0.0.1, actually any address starting with 127, will not
cause any IP packets to leave the computer, much less hit any
firewall. The 127 range contains only loopback addresses. Try
unplugging the network connection and then running the script.
Replies will still happen.

Also note that to be closer to accurate that the parameter should be
one larger. In other words to sleep for 10 seconds use the following:

ping -n 11 127.0.0.1 >NUL

It doesn't make that much difference, but it could.

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 
P

Paul R. Sadowski

Clay Calvert said:
Pinging 127.0.0.1, actually any address starting with 127, will not
cause any IP packets to leave the computer, much less hit any
firewall.

I'm talking about software firewalls. I don't like them but had to test one
and pinging the localhost did set off the warning asking me whether to allow
it or not.
 
C

Clay Calvert

I'm talking about software firewalls. I don't like them but had to test one
and pinging the localhost did set off the warning asking me whether to allow
it or not.

Gotcha. Good point.


Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 
T

Timo Salmi

Steven Adams said:
Under a default Windows XP install there doesn't seem to be a sleep command
available at the command prompt ?

19} How can one build a delay / sleep / wait procedure for a script?

56675 Dec 27 2003 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo
 

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