Discussion:
Something like "choice" (Win7) for WinXP?
(too old to reply)
Kenny McCormack
2024-02-21 19:57:14 UTC
Permalink
Is there something in Windows XP that can be used to make choices in a
batch file?

Under Win7, I use "choice.exe", but I can't seem to get that to work under XP.

I have a vague memory of there being something like this - maybe going back
all the way to DOS days - but I can't remember what it was called now.
--
After 4 years of disastrous screwups, Trump now favors 3 policies that I support:
1) $2K/pp stimulus money. Who doesn't want more money?
2) Water pressure. My shower doesn't work very well; I want Donnie to come fix it.
3) Repeal of Section 230. This will lead to the demise of Face/Twit/Gram. Yey!
JJ
2024-02-22 01:49:06 UTC
Permalink
Post by Kenny McCormack
Is there something in Windows XP that can be used to make choices in a
batch file?
Under Win7, I use "choice.exe", but I can't seem to get that to work under XP.
I have a vague memory of there being something like this - maybe going back
all the way to DOS days - but I can't remember what it was called now.
If your WinXP is 32-bit...

You can use CHOICE.COM (DOS program) from MS-DOS v6.22 or from DOS boot
floppy disk images which are widely availavle in the net. You can use 7-Zip
to open the DSK/IMG floppy disk images.

Alternatively, you can use CHOICE.EXE (DOS program) from FreeDOS.
Kenny McCormack
2024-02-22 13:23:05 UTC
Permalink
Post by JJ
Post by Kenny McCormack
Is there something in Windows XP that can be used to make choices in a
batch file?
Under Win7, I use "choice.exe", but I can't seem to get that to work under XP.
I have a vague memory of there being something like this - maybe going back
all the way to DOS days - but I can't remember what it was called now.
If your WinXP is 32-bit...
You can use CHOICE.COM (DOS program) from MS-DOS v6.22 or from DOS boot
floppy disk images which are widely availavle in the net. You can use 7-Zip
to open the DSK/IMG floppy disk images.
Alternatively, you can use CHOICE.EXE (DOS program) from FreeDOS.
OK - thanks for this response. I think I should be able to find it from
one or some of those sources. I think I have a Win98 VM laying around
somewhere; it might be in there.

I wonder why they left it out of XP???

The following link may have it (haven't checked yet):

http://support.microsoft.com/kb/117600

P.S. The idea of using "set /p" doesn't appeal. The whole point is to
avoid the "having to press enter" issue.
--
No puppet.
No puppet.
You're a puppet.
Kenny McCormack
2024-02-22 14:55:20 UTC
Permalink
Post by JJ
Post by Kenny McCormack
Is there something in Windows XP that can be used to make choices in a
batch file?
Under Win7, I use "choice.exe", but I can't seem to get that to work under XP.
I have a vague memory of there being something like this - maybe going back
all the way to DOS days - but I can't remember what it was called now.
If your WinXP is 32-bit...
You can use CHOICE.COM (DOS program) from MS-DOS v6.22 or from DOS boot
floppy disk images which are widely availavle in the net. You can use 7-Zip
to open the DSK/IMG floppy disk images.
Alternatively, you can use CHOICE.EXE (DOS program) from FreeDOS.
Success!

I was able to boot up an old Win98 VM (hadn't been used since 2016) and
copy the CHOICE.COM from there. It seems to have pretty much the same
functionality as the one in Win7.

A couple of strange things I noticed when running this CHOICE.COM under XP
(in a CMD window):

1) The first time I ran it on XP, it took a long time (maybe 15-30 seconds)
to start up. I was panicked for a bit 'cause I thought it may have
crashed the machine. Anyway, I assume it was loading some 16 bit
subsystem in XP. After that first time, though, it runs fine
(launches right up).
2) It changes my prompt to something weird with ~s in it (i.e.,
everything gets forced to 8.3 conventions). cd'ing to %homepath%
fixes this, so no worries... Still jarring to the eye, though.

A couple of other notes:
1) Still wondering how/why they left this out of XP...
(They must have realized the error of omission when they put Win7 together)
2) In case anyone was wondering, the reason the Win7 version doesn't
work under XP is that it (the Win7 version) is a 64 bit executable.
--
If your answer to the question below is any number other than 1, then you're an atheist.

Q: How many religions are worthy of respect? (i.e., how many religions are valid?)
JJ
2024-02-22 17:39:14 UTC
Permalink
Post by Kenny McCormack
Success!
I was able to boot up an old Win98 VM (hadn't been used since 2016) and
copy the CHOICE.COM from there. It seems to have pretty much the same
functionality as the one in Win7.
A couple of strange things I noticed when running this CHOICE.COM under XP
1) The first time I ran it on XP, it took a long time (maybe 15-30 seconds)
to start up. I was panicked for a bit 'cause I thought it may have
crashed the machine. Anyway, I assume it was loading some 16 bit
subsystem in XP. After that first time, though, it runs fine
(launches right up).
2) It changes my prompt to something weird with ~s in it (i.e.,
everything gets forced to 8.3 conventions). cd'ing to %homepath%
fixes this, so no worries... Still jarring to the eye, though.
DOS programs sometimes go wonky when run in a console window which was
created by a Windows program. The problem is related to switching from
Windows to DOS environment, then back to Windows environment again. FYI,
console window created by DOS and Windows programs, has different set of
rules, limitations, and behaviours. In short, it can be glitchy when mixing
console Windows programs with DOS programs.

If you want Windows version of the CHOICE tool, you can get it from Windows
XP Resource Kit; or from Windows 2003; or from 64-bit version of Windows XP
(get the 32-bit version of the tool). Those Windows can be found in
archive.org, but the XP Resource Kit is hard to find.
Post by Kenny McCormack
1) Still wondering how/why they left this out of XP...
(They must have realized the error of omission when they put Win7 together)
Windows NT's DOS VM is based on MS-DOS v5.0, and MS-DOS 5.0 doesn't have the
CHOICE tool yet. CHOICE was introducted in MS-DOS v6.0.

https://en.wikipedia.org/wiki/Choice_(command)#History

CHOICE was included starting in Windows 2003.

IMO, the tool shouldn't have been included into Windows in the first place,
since it's not part of MS-DOS v5.0; and Windows NT's DOS VM is a light
version of MS-DOS v5.0 (e.g. doesn't include [at least] DOSSHELL and
QBASIC). Hence, it was initially included into Windows Resource Kit rather
than Windows. But I guess Microsoft finds that the specific tool should be
included into Windows in the first place, or maybe Microsoft was urged by
feedbacks to include it into Windows.
Post by Kenny McCormack
2) In case anyone was wondering, the reason the Win7 version doesn't
work under XP is that it (the Win7 version) is a 64 bit executable.
The 32-bit CHOICE.EXE in Windows Vista+ also won't work in earlier Windows
versions since it was built using newer compiler version where the generated
EXE file needs a function which only exist in newer MSVCRT.DLL version. That
newer MSVCRT.DLL version needs a system function which only exist starting
from Windows 2003 or the 64-bit version of Windows XP (i.e. NT 5.2). FYI,
32-bit Windows XP is NT 5.1.
Kenny McCormack
2024-02-25 14:14:02 UTC
Permalink
In article <y20a345edsfj.lk1dfj4b8zdb$***@40tude.net>,
JJ <***@outlook.com> wrote:
...
Post by JJ
DOS programs sometimes go wonky when run in a console window which was
created by a Windows program. The problem is related to switching from
Windows to DOS environment, then back to Windows environment again. FYI,
console window created by DOS and Windows programs, has different set of
rules, limitations, and behaviours. In short, it can be glitchy when mixing
console Windows programs with DOS programs.
If you want Windows version of the CHOICE tool, you can get it from Windows
XP Resource Kit; or from Windows 2003; or from 64-bit version of Windows XP
(get the 32-bit version of the tool). Those Windows can be found in
archive.org, but the XP Resource Kit is hard to find.
(Much more useful info - snipped for this post)

Thanks for all the info. A bit of a history lesson.

Anyway, and FWIW, and all that, in the end, I ended up going with an old
program I'd originally written decades ago for Unix/Linux/POSIX (whatever
and whichever name you prefer), called "pause", that basically implements
for Unix, the functionality of "pause" under DOS/Windows/NT/etc. I know
how to do the "don't wait for enter" thing in Unix, but not in DOS/Windows,
so it was easiest for me to do it that way.

I don't think that my "pause" program would compile under a "generic"
Windows C compiler, since it uses POSIX stuff to handle the terminal. As a
result, the hardest part of the project was getting a working version of
Cygwin for XP, so that I could compile it under Cygwin. The Cygwin project
has gone all 64 bit nowadays; they've completely abandoned the 32 bit
world. However, if you Google "Cygwin for Windows XP", you'll get the
info; you need to go to a site (archive) called "fruitbat" to get the
stuff. But, it actually isn't "fruitbat" anymore; you have to go to
something like "crouchingtiger_fruitbat". But once you have the right
sites, it all works perfectly.

Be aware that GCC is not in the default software load, so be sure to "tick
the box" for GCC, or you won't get it. I had to re-run setup to get GCC.
Also, don't forget the "-X" option on "setup.exe".

So, in case anyone is interested in any of this, I have put the "pause"
source code as well as an EXE and the needed Cygwin DLL here:

http://shell.xmission.com:65401/pause.zip

Note that this "pause" does pretty much everything that CHOICE does (*),
except for the "only accept these keys" part. I could easily hack that
into the C source if I needed it (so far, the need has not arisen).

(*) Actually, the default model is slightly different. It is "press any
key other than escape to continue". Pressing Escape generates an error
return (errorlevel != 0); any other key returns success.
--
A racist, a Nazi, and a Klansman walk into a bar...

Bartender says, "What will it be, Mr. Trump?"
R.Wieser
2024-02-22 07:44:13 UTC
Permalink
Kenny,
Post by Kenny McCormack
I use "choice.exe", but I can't seem to get that to work under XP.
Its always a good idea to specify what "can't seem to get that to work"
means to you. Your house blows up ? Your cat/dog starts to attack you ?
Your 'puter crashes and reboots ? A "wrong OS version" response ?
Anything else ? (and as you seem to have already used it under Win7 I'm
skipping the "maybe you misuderstood how its supposed to work?" possibility)
Post by Kenny McCormack
I have a vague memory of there being something like this - maybe
going back all the way to DOS days - but I can't remember what it
was called now.
It was called the same - for the versions that included it. But there have
been multiple non-MS versions of the same around. Though mostly without the
time-out feature.

Maybe you can use this (SET /P) :

https://stackoverflow.com/questions/566944/windows-batch-choice-command-for-windows-xp-2003

Regards,
Rudy Wieser
Mr. Man-wai Chang
2024-02-29 16:13:45 UTC
Permalink
Post by Kenny McCormack
Is there something in Windows XP that can be used to make choices in a
batch file?
Under Win7, I use "choice.exe", but I can't seem to get that to work under XP.
I have a vague memory of there being something like this - maybe going back
all the way to DOS days - but I can't remember what it was called now.
Back then, I barely remember I wrote a simple Turbo C program to do
something similar in DOS 3.30. :)

Loading...