China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-02 11:39
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Encountered a problem when learning CHOICE View 4,891 Replies 22
Original Poster Posted 2006-10-21 22:28 ·  中国 黑龙江 佳木斯 电信
初级用户
Credits 25
Posts 7
Joined 2006-10-13 06:50
19-year member
UID 65582
Status Offline
Try to edit batch files with CHOICE, but can't experiment under XP, always prompts: 'CHOICE' is not an internal or external command, nor is it a runnable program or batch file.

What should I do????

──────────────── Moderation Record ────────────────
Execution: namejm
Original title: Encounter a problem when learning CHOICE
Description: The title is too vague, which is not conducive to forum search and management, please modify the title within three days.
Prompt: To modify the title, please click Edit at the bottom right of the current post, after modification, press Edit Post
Penalty: As a new forum user, temporarily no penalty; if the title is not modified after three days, 2 points will be deducted as punishment, and the moderator will force the title modification. Please click here to read the forum posting regulations, so as to avoid violating the regulations in future discussions.
──────────────── Moderation Record ────────────────

[ Last edited by namejm on 2006-11-20 at 10:59 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+1 2009-02-21 00:40
Floor 2 Posted 2006-10-22 00:09 ·  中国 浙江 温州 电信
中级用户
★★
Credits 458
Posts 196
Joined 2006-10-05 12:04
19-year member
UID 64614
Status Offline
It seems that XP is not installed with choice by default:P
Floor 3 Posted 2006-10-22 00:42 ·  中国 黑龙江 佳木斯 电信
初级用户
Credits 25
Posts 7
Joined 2006-10-13 06:50
19-year member
UID 65582
Status Offline
How can I install it?
Floor 4 Posted 2006-10-22 01:12 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
I've pressed a choice.exe for Windows Server 2003 for you. Copy it to your XP and see if it can be used :)


C:\TEMP>choice.exe /?

CHOICE

Description:
This tool allows the user to select an item from a choice list and returns the index of the selected item.

Parameter List:
/C choices Specifies the list of options to create. The default list is "YN".

/N Hides the option list in the prompt. The message preceding the prompt is displayed, and the options remain enabled.

/CS Allows case-sensitive options to be selected. By default, this tool is case-insensitive.

/T timeout The number of seconds to pause before making the default selection. Acceptable values are from 0 to 9999. If 0 is specified, there will be no pause and the default option will be selected.

/D choice Specifies the default option after nnnn seconds. The character must be in the set of choices specified with /C; also, /T must be used to specify nnnn.

/M text Specifies the message to display before the prompt. If not specified, the tool only displays the prompt.

/? Displays help message.

Note:
The ERRORLEVEL environment variable is set to the key index selected from the choice set. The first choice listed returns 1, the second returns 2, and so on. If the key pressed is not a valid choice, the tool beeps. If the tool detects an error condition, it returns an ERRORLEVEL value of 255. If the user presses Ctrl+Break or Ctrl+C, the tool returns an ERRORLEVEL value of 0. When using the ERRORLEVEL parameter in a batch program, order the parameters in descending order.

Examples:
CHOICE /?
CHOICE /C YNC /M "Press Y to confirm, N to reject, or C to cancel."
CHOICE /T 10 /C ync /CS /D y
CHOICE /C ab /M "Select a for option 1, b for option 2."
CHOICE /C ab /N /M "Select a for option 1, b for option 2."
Attachments
choice.rar (16.41 KiB, Credits to download 1 pts, Downloads: 150)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 5 Posted 2006-10-22 01:16 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  The choice command is not built-in in XP by default, right?

  I'll also download it and give it a try~
Floor 6 Posted 2006-10-22 04:03 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Vista also supports choice, it seems that Microsoft really has a hard time making a choice

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 7 Posted 2006-10-22 08:59 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 8 Posted 2006-10-30 07:01 ·  中国 广东 广州 电信
新手上路
Credits 10
Posts 5
Joined 2006-10-30 04:59
19-year member
UID 68843
Gender Male
Status Offline
Floor 9 Posted 2006-10-30 07:10 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline


@echo off
set /p a=Please enter the value you want to assign to variable a:
echo %a%
pause

Floor 10 Posted 2006-10-30 07:13 ·  中国 广东 广州 电信
新手上路
Credits 10
Posts 5
Joined 2006-10-30 04:59
19-year member
UID 68843
Gender Male
Status Offline
Got it~~~~~~~
Floor 11 Posted 2006-10-30 07:14 ·  中国 广东 广州 电信
新手上路
Credits 10
Posts 5
Joined 2006-10-30 04:59
19-year member
UID 68843
Gender Male
Status Offline
Thanks
Floor 12 Posted 2006-11-21 09:23 ·  中国 浙江 杭州 电信
新手上路
Credits 2
Posts 1
Joined 2006-03-16 23:05
20-year member
UID 52221
Status Offline
Floor 13 Posted 2006-11-21 09:40 ·  中国 广东 深圳 罗湖区 电信
初级用户
★★
Credits 142
Posts 61
Joined 2006-06-01 19:41
20-year member
UID 56391
Gender Male
Status Offline
You can copy the choice command under Win2003 to XP.
Floor 14 Posted 2007-04-14 00:31 ·  中国 广东 汕头 电信
新手上路
Credits 2
Posts 1
Joined 2006-10-30 04:17
19-year member
UID 68840
Gender Male
Status Offline
Thanks
Floor 15 Posted 2007-04-27 06:00 ·  中国 广东 深圳 福田区 电信
新手上路
Credits 2
Posts 1
Joined 2007-04-27 05:40
19-year member
UID 86618
Gender Female
Status Offline
I also encountered such a problem:
Try to use CHOICE to edit a batch file, but it cannot be experimented under XP. It always prompts: 'CHOICE' is not an internal or external command, nor is it a runnable program or batch file.
Forum Jump: