标题: 请教批处理的问题
[打印本页]
作者: 19890321
时间: 2006-3-4 11:25
标题: 请教批处理的问题
@echo off
choice /c:tde type,del,end
if errorlevel 3 goto c
if errorlevel 2 goto b
if errorlevel 1 goto a
:a
c:\
type 222.txt
echo.
pause
goto b
:b
c:
del 222.txt
cls
goto c
:c
echo good bye
============
@echo off
choice /c:tde type,del,end
if errorlevel 3 goto a
if errorlevel 2 goto b
if errorlevel 1 goto c
:a
c:\
type 222.txt
echo.
pause
goto b
:b
c:
del 222.txt
cls
goto c
:c
echo good bye
为什么第一个按照命令执行 而第二个却按照正常顺序执行???
作者: bagpipe
时间: 2006-3-4 11:34
if errorlevel 3 goto c
if errorlevel 2 goto b
if errorlevel 1 goto a
和
if errorlevel 3 goto a
if errorlevel 2 goto b
if errorlevel 1 goto c
能一样吗?顺序本身就不一样,执行的顺序也就不一样了
作者: 19890321
时间: 2006-3-4 12:31
@echo off
choice /c:tde type,del,end
if errorlevel 1 goto c
if errorlevel 2 goto b
if errorlevel 3 goto a
:a
c:\
type 222.txt
echo.
pause
goto b
:b
c:
del 222.txt
cls
goto c
:c
echo good bye
这个呢
作者: bagpipe
时间: 2006-3-4 13:14
这个啊,呵呵,不管你按哪个最后就显示 good bye,呵呵
作者: wudongjin
时间: 2006-5-28 14:44
不太看的懂,晕。
作者: shuiruobing
时间: 2006-5-31 14:41
批处理很简单啊
作者: kekewithdos
时间: 2006-6-3 13:20
新手上路 学习了 谢谢
作者: xjmxjm1234
时间: 2006-6-3 15:17
Quote: |
@echo off
choice /c:tde type,del,end
if errorlevel 1 goto c
if errorlevel 2 goto b
if errorlevel 3 goto a
:a
c:\
type 222.txt
echo.
pause
goto b
:b
c:
del 222.txt
cls
goto c
:c
echo good bye
这个呢 |
|
Quote: |
这个啊,呵呵,不管你按哪个最后就显示 good bye,呵呵 |
|
严重支持4楼的观点
if errorlevel n <command>
指的是在错误返回码
大于或等于n时,执行后面的命令
所以对于:
if errorlevel 1 goto c
来说,不管选什么都会转移到 :c ,等着你的只有 显示 good bye 了
所以在判断错误返回码时,一定要从
最高位开始判断!
[
Last edited by xjmxjm1234 on 2006-6-3 at 15:19 ]
作者: ahqueer
时间: 2006-6-3 20:37
新手上路 学习了 谢谢
作者: htysm
时间: 2006-6-26 17:43
怎么我运行这个批处理时却进入了一个死循环.
作者: fastslz
时间: 2006-6-26 18:28
执行完a:后少了个goto b
作者: arding
时间: 2006-6-27 11:59
楼主让我们玩“大家来找碴”的游戏吗?BS一下。
作者: yyz985
时间: 2006-6-27 15:01
if %errorlevel%==1 ...
if %errorlevel%==2 ...
作者: 不得不爱
时间: 2006-6-27 17:38
楼主的批处理里的GOTO用的有的问题:看下面的
@echo off
choice /c:tde type,del,end
if errorlevel 3 goto c
if errorlevel 2 goto b
if errorlevel 1 goto a
:a
c:\
type 222.txt
echo.
pause
goto end
:b
c:
del 222.txt
cls
goto end
:c
echo good bye
:end
作者: xiongwei2624
时间: 2006-6-29 16:03
choice /c:tde type,del,end
什么意思!!
作者: arding
时间: 2006-6-30 12:51
Quote: |
Originally posted by xiongwei2624 at 2006-6-29 16:03:
choice /c:tde type,del,end
什么意思!! |
|
choice.exe是某些DOS版本中的外部命令,用于给操作者提供选择
批处理分支的界面,参数中:
/c:tde 表示可以敲击键盘的t d 或者 e键,进行选择;
type,del,end 是命令提供的提示信息。
作者: buddiyar
时间: 2006-7-9 18:12
Quote: |
Originally posted by xiongwei2624 at 2006-6-29 16:03:
choice /c:tde type,del,end
什么意思!! |
|
呵呵 小的对choice还是懂得一点的
只是苦于理科出身语文水平不怎么地啊
就不好做不精确的解释了
以免贻害后人 呵呵
提示可以去查看自带帮助文件啊
在cmd下输入choice /? 你就明白了 呵呵
在友情提示:
choice在win98以后ms就不再支持使用了啊
呵呵 所以还是要在win98下才能看的