Command interpreter delay??

B

Bluu

I am using command interpreter to run a batch file.
my operating system is win xp

I was wondering if anyone might know a set of lines i
could use with a batch file that would cause a delay for
say 10 seconds?

don't need to to display anything or do anything during
the delay unless its easy then that may be cool.

but all i need is a way to type a few lines that would
cause it to just stop for 10 seconds or so.

any ideas?
 
K

Ken Blake

In
Bluu said:
I am using command interpreter to run a batch file.
my operating system is win xp

I was wondering if anyone might know a set of lines i
could use with a batch file that would cause a delay for
say 10 seconds?

don't need to to display anything or do anything during
the delay unless its easy then that may be cool.

but all i need is a way to type a few lines that would
cause it to just stop for 10 seconds or so.


Will pause do what you want? It suspends processing of a batch
program and displays the message Press any key to continue . . .
 
D

David Candy

There are a million sleep utilities in the world, incl in MS Resource Kits/


This code that I was working on earlier today almost works
Set Secs=%time:~-2%
echo %secs%
Set /a final=%time:~-2% - %secs%
echo %final%
:Loop
If not %final%==10 goto :loop
Pause

But you need to set delayed variable expansion. I don't have time to finish it.
See Set /?
if /?
for /?
and cmd /?
And also in help as the help is dirreent
 
D

David Candy

I put loop in wrong place. Wish I noticed that when I spent an hour trying to work out why is wasn't working. That's what you get when concentrating on stupid ~ rather than program logic. What a dumb language.


Set Secs=%time:~-2%
echo %secs%
:Loop
Set /a final=%time:~-2% - %secs%
echo %final%
If not %final%==10 goto :loop
Pause

--
----------------------------------------------------------
http://www.g2mil.com/Dec2003.htm
There are a million sleep utilities in the world, incl in MS Resource Kits/


This code that I was working on earlier today almost works
Set Secs=%time:~-2%
echo %secs%
Set /a final=%time:~-2% - %secs%
echo %final%
:Loop
If not %final%==10 goto :loop
Pause

But you need to set delayed variable expansion. I don't have time to finish it.
See Set /?
if /?
for /?
and cmd /?
And also in help as the help is dirreent
 
D

David Candy

You have to take out the echo (that's onlythere to test) and use @echo off as it can take longer than 1 sec to do the loop so it might go 9 to 11 secs.

--
----------------------------------------------------------
http://www.g2mil.com/Dec2003.htm
I put loop in wrong place. Wish I noticed that when I spent an hour trying to work out why is wasn't working. That's what you get when concentrating on stupid ~ rather than program logic. What a dumb language.


Set Secs=%time:~-2%
echo %secs%
:Loop
Set /a final=%time:~-2% - %secs%
echo %final%
If not %final%==10 goto :loop
Pause

--
----------------------------------------------------------
http://www.g2mil.com/Dec2003.htm
There are a million sleep utilities in the world, incl in MS Resource Kits/


This code that I was working on earlier today almost works
Set Secs=%time:~-2%
echo %secs%
Set /a final=%time:~-2% - %secs%
echo %final%
:Loop
If not %final%==10 goto :loop
Pause

But you need to set delayed variable expansion. I don't have time to finish it.
See Set /?
if /?
for /?
and cmd /?
And also in help as the help is dirreent
 
T

Torgeir Bakken (MVP)

Bluu said:
I am using command interpreter to run a batch file.
my operating system is win xp

I was wondering if anyone might know a set of lines i
could use with a batch file that would cause a delay for
say 10 seconds?

Hi

You can do a sleep using ping.exe (not CPU intensive).

Example on sleep approx. 10 seconds (number behind -n is seconds +1):

ping.exe -n 11 localhost >nul


Alternatively, you can use the sleep.exe in the Windows Server 2003 Resource
Kit Tools.
http://www.microsoft.com/downloads/...69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

The download link above also lists all the utilities that is in the RK.
The kit will install on WinXP or later.
 

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