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

SET /P in batch file - Default value after timeout for user prompt

2,660 views
Skip to first unread message

paul.rober...@hotmail.co.uk

unread,
Oct 3, 2008, 5:15:13 PM10/3/08
to
Hello!

Can anyone help please? I have a problem with something that used to
be easy with the CHOICE command in Win9x batch files, but I think I
must be missing something, as I can't find out how to do it using SET /
P, the replacement in WIN XP. Does anybody know if and how to get a
batch file to wait a limited time for user input, and to use a default
value
instead, if the time expires without user input? I thought it might be
possible to do something equivalent to

SET /P:30,Y choice=Enter your choice
(where it would wait 30s and then choose Y by default)

I know this syntax is just made up, its just an example of what I was
trying to do,
but does anybody know how I would go about doing this sort of thing? I
can't
find any relevant documentation anywhere .... any advice very
gratefully received!

Thanks very much!

contrex

unread,
Oct 3, 2008, 6:29:53 PM10/3/08
to
Can't be done with set /p. You'd need either a Microsoft or 3rd party
app.

Why don't you get the choice.exe from a Windows 98 CD, or download
Windows NT 3.5 Resource Kit which contains CHOICE.EX_ (needs EXPANDing
to choice.exe) from Microsoft Ftp site:

i386.exe (self extracting archive)

ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt35/i386/i386.exe

Timo Salmi

unread,
Oct 3, 2008, 9:16:17 PM10/3/08
to
14} Help! My old batch files won't work since there is no choice.com
http://www.netikka.net/tsneti/info/tscmd014.htm

All the best, Timo

--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

ten.n...@virgin.net

unread,
Oct 5, 2008, 11:31:36 AM10/5/08
to
On Sat, 04 Oct 2008 04:16:17 +0300, Timo Salmi wrote:

> 14} Help! My old batch files won't work since there is no choice.com
> http://www.netikka.net/tsneti/info/tscmd014.htm
>
> All the best, Timo

Just to expand a little on Timo's response:

You can use CHOOSE.EXE from
TSUTLF17.zip - http://garbo.uwasa.fi/pub/pc/ts/tsutlf17.zip
Or
TSCMD.ZIP - http://garbo.uwasa.fi/pub/pc/link/tscmd.zip

Usage: CHOOSE [/c[:]keys] [/?|/h] [/n] [/s] [/t[:]c,nn] [/x] [text]
the prompt keys ─┘ │ │ │ │ │ │ │
Help ─┘ │ │ │ │ │ │
No default prompt (only user text) ─┘ │ │ │ │ │
apply case Sensitivity ─┘ │ │ │ │
default key after timeout (must be among keys) ─┘ │ │ │
Timeout in seconds ─┘ │ │
Output @set choose_=returnCode ─┘ │
user's text prompt ─┘

An Example of which can be found here

0 new messages