Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Time delay in batch file

2 views
Skip to first unread message

Guy Laister

unread,
Jun 7, 2001, 11:01:50 AM6/7/01
to
I need to run a batch file every 5 minutes or so. I've noticed all the
attention in this type of problem in using 'choice'. Unfortunately I
need to delay for greater than 99 seconds. I've also heard talk of
'Soon' and 'Sleep' but I cannot access/run these functions.

Any help would be appreciated.

Guy

Phil Robyn

unread,
Jun 7, 2001, 12:05:40 PM6/7/01
to
Guy Laister wrote:

It appears from your message headers that you are using WinNT.
NT-related questions are best addressed to the alt.msdos.batch.nt
newsgroup.

Soon and Sleep are part of the WinNT Resource Kit. You can
obtain a replacement for Soon ('Rsoon' - a batch file) at

http://www.jsiinc.com

click on 'NT Reg Hacks' and search for 'Rsoon'.

To have a batch job repeat every five minutes, you would add
the following to the logical end of your existing batch file:

call RSOON 300 %comspec% /c "%~f0 %*"


--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l


ram

unread,
Jun 7, 2001, 12:46:11 PM6/7/01
to
For similar problems I use loop in the batch file
:: WAITMORE.BAT
@ECHO OFF
IF (%1)==() GOTO USAGE
:LOOP
IF (%1)==() GOTO DONE
ECHO WAITING FOR %1 SECS
TYPE NUL | choice /c:d /td,%1>NUL
SHIFT
GOTO LOOP
:DONE
ECHO. ...DONE
GOTO EOF
:USAGE
ECHO.USAGE : %0 99 99 99 (...)
:EOF
::===
Hope this helps.
Ram

Guy Laister

unread,
Jun 8, 2001, 3:54:31 AM6/8/01
to
I've just started programming batch files and not sure whether I'm missing
something. I've saved your code as a batch file and then types the name of
the file followed by a number (300) at the command prompt. The first 5 lines
of code execut fine (i.e. it types 'Waiting for 300 seconds"), but then it
says 'The name specified is not recognised as an
internal..................).

What am I doing wrong? Thanks again

Guy Laister

unread,
Jun 8, 2001, 3:58:08 AM6/8/01
to
I think it may be the 'choice' command. For some reason, I don't seem to be able
to access this command????????

Phil Robyn

unread,
Jun 8, 2001, 4:29:09 AM6/8/01
to
Guy Laister wrote:
>
> I think it may be the 'choice' command. For some reason, I don't seem to be able
> to access this command????????
>
> Guy Laister wrote:
>
> > I've just started programming batch files and not sure whether I'm missing
> > something. I've saved your code as a batch file and then types the name of
> > the file followed by a number (300) at the command prompt. The first 5 lines
> > of code execut fine (i.e. it types 'Waiting for 300 seconds"), but then it
> > says 'The name specified is not recognised as an
> > internal..................).
> >
> > What am I doing wrong? Thanks again

According to your message headers, you are using NT. NT-related questions
should be posted to the alt.msdos.batch.nt newsgroup. Choice does not
'come standard' with NT; it's included in the Resource Kit. Also, the
maximum amount of time that you can delay with Choice is 99 seconds anyway.

People will tell you that you can use Choice from Win9x, etc., etc.,
but experience proves that no version of Choice works reliably on NT,
especially when used to implement a delay (as opposed to its original
purpose of accepting a single keystroke). A single invocation of
Choice may work as intended; but since NT is a true multi-tasking
environment, once you start writing batch files that use Choice, either
interactively to accept keystrokes or non-interactively to effect time
delays, you will soon discover that multiple concurrent invocations of
Choice will simply clobber each other.

If you want to run a batch file once every so many minutes, just put
the following at the logical end of your batch file:

SOON (number of seconds) %comspec% /c "%~f0 %*"

So when you run it the first time, it will then reschedule itself to
run again in (number of seconds). By the way, you must start the
Scheduler Service to be able to do this; type the command

net start schedule

at the CMD prompt.

SOON is also in the Resource Kit. If you don't have the Resource Kit,
you can download a freeware replacement for SOON (RSOON) from
http://www.jsiinc.com - click on NT Reg Hacks and search for RSOON.
In which case, you would put at the logical end of your batch file

RSOON (number of seconds) ....

There is documentation for RSOON at jsiinc.

Walter Briscoe

unread,
Jun 8, 2001, 6:03:05 AM6/8/01
to
In article <3B208590...@nu.ac.za> of Fri, 8 Jun 2001 09:58:08 in
alt.msdos.batch, Guy Laister <lais...@nu.ac.za> writes

>I think it may be the 'choice' command. For some reason, I don't seem to be able
>to access this command????????
>
>Guy Laister wrote:
>
>> I've just started programming batch files and not sure whether I'm missing
>> something. I've saved your code as a batch file and then types the name of
>> the file followed by a number (300) at the command prompt. The first 5 lines
>> of code execut fine (i.e. it types 'Waiting for 300 seconds"), but then it
>> says 'The name specified is not recognised as an
>> internal..................).
>>
>> What am I doing wrong? Thanks again
[snip]
When I started using Usenet, it was netiquette to put answers at the end
or interleave them and quote no more than was necessary to put the
answer in context. YMMV.

'The name specified is not recognised as an internal...' suggests your
shell is cmd and that your OS is NT. choice is not supplied by default
in that environment. A W9X choice file is portable to NT and the
question of choice in NT has already been asked many times. I would give
a better answer if I had it. I suggest you research an answer at
http://groups.google.com/advanced_groups_search
I have no immediate interest in such an answer. Such an answer may
appear here anyway within a couple of days. You or I may also get flames
suggesting the question is not topical.

I CAN tell you that the parameter to choice is limited to 99 seconds.
You may also like to look at Windows Script Host unless you are
committed to DOS technology.
--
Walter Briscoe

Message has been deleted

ram

unread,
Jun 8, 2001, 8:59:53 AM6/8/01
to
Guy,
Choice is limited to 99 secs. and therefore for 300 secs wait, your
command line should be
WAITMORE.BAT 99 99 99 3 (99+99+99+3=300)
Ram
Message has been deleted

Timo Salmi

unread,
Jun 8, 2001, 3:33:53 PM6/8/01
to
Outsider <ipros...@yahoo.com> wrote:
> Choice.com used to be available here:

There also is a clone

ftp://garbo.uwasa.fi/pc/ts/tsutlf16.zip Sixth set of Utilities, T.Salmi
Filename Comment Date Time
-------- -------------------------------- ---- ----
ADVDATE.EXE Advance system clock's date Jan-31-2000 07:16:48
CHOOSE.EXE Ask questions in batch files Jan-31-2000 07:17:16 <---
CHTEST.BAT An example of using CHOOSE.EXE Aug-07-1993 14:17:54
DELEDIR.EXE Generalized delete directory Jan-31-2000 07:19:06
FILE_ID.DIZ Brief characterization of TSUTLF Jan-31-2000 07:14:20
GOTODIR.EXE Generalized change directory Jan-31-2000 07:20:20
MAKEDIR.EXE Generalized create directory Jan-31-2000 07:20:50
STRINGS.EXE Find a file's embedded strings Jan-31-2000 07:21:50
STRMEMO.EXE Find strings in your PC's memory Jan-31-2000 07:23:24
TSPROG.INF List of programs from Timo Salmi Jan-20-2000 12:21:36
TSUTLF.INF Document (a readme) Feb-01-2000 06:36:38
TSUTLF.NWS News announcements about tsutlf Feb-01-2000 06:37:22
VAASA.INF Info: Finland, Vaasa, U of Vaasa Oct-18-1997 13:18:46
---- ------ ------ -----
0013 116890

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

Rik D'haveloose

unread,
Jun 9, 2001, 5:26:53 PM6/9/01
to
Timo Salmi wrote in AMB:

> > Choice.com used to be available here:
> There also is a clone
>
> ftp://garbo.uwasa.fi/pc/ts/tsutlf16.zip Sixth set of Utilities, T.Salmi
> Filename Comment Date Time
> -------- -------------------------------- ---- ----
> CHOOSE.EXE Ask questions in batch files Jan-31-2000 07:17:16 <---

sorry to bother you, but it suddenly came into my mind: i would prefer
to have in the time-column some filesize-column instead. I believe time
is less important for the reader (as date is given), although it
concerns certainly compact files, it may be more informative, and even
be an asset against the standard tool (amongst others).

Just some thinking here. (yes i saw/know, size of zip is given)
and even wondering why i even suggest it.

--
Lieve - Ri(n)ksken(s)
TUF Greetings from Rumbeke, Belgium

Please use only 1 e-mail adress if reply !


g...@infinet.com

unread,
Jun 12, 2001, 12:30:43 AM6/12/01
to
In alt.msdos.batch Phil Robyn <pro...@zipuclink.berkeley.edu> wrote:

: People will tell you that you can use Choice from Win9x, etc., etc.,


: but experience proves that no version of Choice works reliably on NT,
: especially when used to implement a delay (as opposed to its original
: purpose of accepting a single keystroke). A single invocation of
: Choice may work as intended; but since NT is a true multi-tasking
: environment, once you start writing batch files that use Choice, either
: interactively to accept keystrokes or non-interactively to effect time
: delays, you will soon discover that multiple concurrent invocations of
: Choice will simply clobber each other.

I've verified this by running CHOICE.EXE with the /t option in two command
windows. The one started first never times out, although it will respond
to a keystroke. Does CHOICE work correctly in this situation under Win
99/98/Me?

--
Gary L. Smith g...@infinet.com
Columbus, Ohio

William Allen

unread,
Jun 12, 2001, 2:03:43 AM6/12/01
to
<g...@infinet.com> wrote in message

> In alt.msdos.batch Phil Robyn wrote:
>
> : People will tell you that you can use Choice from Win9x, etc., etc.,
> : but experience proves that no version of Choice works reliably on NT,
> : especially when used to implement a delay (as opposed to its original
> : purpose of accepting a single keystroke). A single invocation of
> : Choice may work as intended; but since NT is a true multi-tasking
> : environment, once you start writing batch files that use Choice, either
> : interactively to accept keystrokes or non-interactively to effect time
> : delays, you will soon discover that multiple concurrent invocations of
> : Choice will simply clobber each other.
>
> I've verified this by running CHOICE.EXE with the /t option in two command
> windows. The one started first never times out, although it will respond
> to a keystroke. Does CHOICE work correctly in this situation under Win
> 99/98/Me?

Yes. If you invoke several "choice /c:d /td,nn>NUL" instances, each runs
to completion separately in the expected time (according to nn = 1 - 99).

However, default CPU usage by each is high, and the rest of the system
suffers a great deal if you run several. At the very least, each instance
needs its own .PIF with idle sensitivity tuned to fairly high (but _not_ the
maximum, or they will all stop/lose time as soon as they lose focus).

It's certainly not the best way to implement delays, but it's a handy kludge
for odd occasions for the process with focus.

--
William Allen


Jean Pierre Daviau

unread,
Jun 13, 2001, 3:39:59 PM6/13/01
to
There was an exe named wait that could be use by batch file, very efficient.
Maybe I stiill have it.


"William Allen" <ma...@mayfly13.fsnet.co.uk> wrote in message
news:9g4dho$75enp$1...@ID-55970.news.dfncis.de...

0 new messages