@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
@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
什么意思!!