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-06-30 05:00
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » What can replace the CHOICE command under XP? View 849 Replies 5
Original Poster Posted 2006-04-11 17:17 ·  中国 广东 广州 电信
初级用户
Credits 100
Posts 34
Joined 2006-04-05 05:13
20-year member
UID 53340
Gender Male
Status Offline
Everyone:
Does anyone know what can be used under XP to replace the CHOICE command? I wrote a batch file and need to use CHOICE. It passed testing under WIN2003. But I ran into trouble on the LAN, because quite a large number of the machines are XP.
Could someone help me out? Thanks!
Floor 2 Posted 2006-04-11 18:03 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
You can consider using SET /P
set /p select=Please enter your selection:
if "%select%"=="1" command
if "%select%"=="2" command
QQ:366840202
http://chenall.net
Floor 3 Posted 2006-04-12 15:31 ·  中国 广东 广州 白云区 电信
初级用户
Credits 100
Posts 34
Joined 2006-04-05 05:13
20-year member
UID 53340
Gender Male
Status Offline
To the expert in reply #2, if something other than 1 or 2 is entered, then it won't be easy to control. What should be done?
Floor 4 Posted 2006-04-12 16:05 ·  中国 广东 广州 白云区 电信
初级用户
Credits 100
Posts 34
Joined 2006-04-05 05:13
20-year member
UID 53340
Gender Male
Status Offline
Reply #2, thanks, you gave me an idea. I wrote one, and now the main problem is that it can't make a default selection. Please help me think of a solution, thanks.

@echo off
set /p select=Please enter your selection:

if "%select%"=="1" (goto 1) else (goto 2)

:1
command
goto end

:2
if "%select%"=="2" (command) else (goto end)

:end
pause
Floor 5 Posted 2006-04-12 20:58 ·  中国 福建 三明 电信
中级用户
★★
Credits 316
Posts 83
Joined 2005-03-01 00:00
21-year member
UID 36626
Gender Male
Status Offline
@echo off

:choose

set /p select=Please enter your selection:

if "%select%"=="1" echo Select 1 && goto tag

if "%select%"=="2" echo Select 2 && goto tag

::The following is the default option pressing Enter directly means the default selection
if "%select%"=="" echo Default selection && goto tag

cls

echo *************WRONG INPUT**********

goto choose

:tag

pause

[ Last edited by smileseeker on 2006-4-12 at 21:04 ]
Floor 6 Posted 2006-04-13 03:45 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Can it be like choice, where you set a time and if no key is pressed it automatically goes to the default selection?
Forum Jump: