@echo off
echo please enter y or no to continue :: y/ n is jumping switch, you can also change this prompt.
set /p choice=
if {%choice%}=={} echo You entered nothing.
if {%choice%}=={y} goto :yes :: one switch else (
if {%choice%}=={n} goto :no :: another switch else (
echo you entered an identifiable word.
)
)
echo press anykey to exit.
pause >nul
:yes
echo yes
echo press anykey to exit.
pause >nul
:no
echo no
echo press anykey to exit.
pause >nul
[ Last edited by scriptor on 2006-12-23 at 02:47 PM ]作者: scriptor 时间: 2006-12-24 03:44 标题: Remark
Quote:
Originally posted by scriptor at 2006-12-23 14:38:
对于没有choice.exe 的兄弟们,这是一个小玩意儿
choice.bat
@echo off
echo please enter y or no to continue :: y/ n is
set /p choice=
if {%choice%}=={} echo You entered n ...
The symbol "::" just is a remark.
By the way , i hope anyone can create a new batch file to reach your own purpose. But not just follow the article.
Be Imaging by youself.
Thanks, it's my fool opinion. Any wrong , please point out mistakes so that they can be corrected.
Many thanks!作者: lxmxn 时间: 2006-12-24 04:36
问题很多。
1、:yes 子程序段和 :no 程序段没有相应的跳转语句 goto .
2、if 加上 /i 参数可以避免输入大写的 Y / N 导致程序显示错误 .
3、就是版面吧,感觉比较乱 .
几点小建议,兄勿怪 .作者: scriptor 时间: 2006-12-24 04:52 标题: 哦??
Quote:
Originally posted by lxmxn at 2006-12-23 15:36:
问题很多。
1、:yes 子程序段和 :no 程序段没有相应的跳转语句 goto .
2、if 加上 /i 参数可以避免输入大写的 Y / N 导致稠...
我在我的机器上调试通过,
1、:yes 子程序段和 :no 程序段没有相应的跳转语句 goto .
有goto 的啊
关于第二点本人完全接受,多谢指点.
第三点我保留意见,呵呵作者: zh159 时间: 2006-12-24 08:23 @echo off
echo please enter y or no to continue :: y/ n is jumping switch, you can also change this prompt.
set /p choice=
if {%choice%}=={} echo You entered nothing.
if {%choice%}=={y} goto :yes :: one switch else (
if {%choice%}=={n} goto :no :: another switch else (
echo you entered an identifiable word.
)
)
echo press anykey to exit.
pause >nul
这里没有跳转语句,会继续执行下面的命令