Board logo

标题: 錯誤輸入次數限制 [打印本页]

作者: shmilyfriend     时间: 2010-7-10 10:10    标题: 錯誤輸入次數限制

我是新人。。寫了一個bat .
我限定了輸入只能在1-8之間,如果輸入為空 或者大於等於9 或者其他的都
顯示重新輸入。。

但是我該如何限定 錯誤輸入的次數。。
比如  當連續錯誤輸入次數=5時。強行退出。。
該如何實現。。




@echo off
title Easy Go!       %username%  - %date%  -  %time%!
color 7F
mode con cols=70 lines=15

echo Read carefully for the first time  
echo 1.If you need help please input 7!
echo 2.If you have some good suggestions
echo   can send mails to "shmilyfriend@sina.com" or shmilyfriend@126.com


echo Please input the number




:shuru
set /p i=i:
if "%i%"=="" goto shuru
if %i% GEQ 9 goto tishi




if "%i%"=="1" GOTO labsys
if "%i%"=="2" GOTO change_window
if "%i%"=="3" GOTO Infor_window
if "%i%"=="4" GOTO QQ
if "%i%"=="5" GOTO color ball
if "%i%"=="6" GOTO sina
if "%i%"=="7" GOTO help
if "%i%"=="8" GOTO 88


:tishi
echo wrong number! pls input again
GOTO shuru

:record
echo    %date% -%time% -%username% use %i% >>d:\test1.txt
exit

:color ball
start "" "D:\03.exe"
goto record
exit

:QQ
start "" "D:\program files\tencent\qq\bin\qq.exe"
goto record
exit

:help
echo 1 :labsys
echo 2:修改窗口  
echo 3:提示窗口
echo 4:QQ  
echo 5:彩球  
echo 6:Sina
echo 7:離開
echo 8:幫助。。。
goto shuru

:88
msg %username% best wishes and see you next time。。。
goto record
exit

:labsys
start "" "D:\桌面資料\tool\169-0327.exe"
goto record
exit

:change_window
start "" "D:\桌面資料\tool\修改窗口0324.exe"
goto record
exit

:Infor_window
start "" "D:\桌面資料\tool\提示窗口.exe"
goto record
exit

:sina
start "" "D:\Program Files\TheWorld 2.0\TheWorld.exe" "http://mail.sina.com.cn/"
goto record
exit
作者: doslike     时间: 2010-7-10 11:18
这很简单
在密码验证前面加上
:check
if exist c:\5.pwd goto exit
if exist c:\4.pwd echo 123>5.pwd
if exist c:\3.pwd echo 123>4.pwd
if exist c:\2.pwd echo 123>3.pwd
if exist c:\1.pwd echo 123>2.pwd
if not exist c:\1.pwd echo 123>1.pwd






if "%i%"=="1" GOTO labsys
if "%i%"=="2" GOTO change_window
if "%i%"=="3" GOTO Infor_window
if "%i%"=="4" GOTO QQ
if "%i%"=="5" GOTO color ball
if "%i%"=="6" GOTO sina
if "%i%"=="7" GOTO help
if "%i%"=="8" GOTO 88
在这后面加上
if "%i%" gtr "8" goto
作者: doslike     时间: 2010-7-10 11:29
在后面加上exit部分
:exit
ECHO 123>input.cde
attrib +r +h .\input.cde
echo You cann't input the password!
echo Because you input FIFTH password were wrong.
echo There is any thing-wrong with the progam,
echo after 3 sec. progam EXIT!!
ping -n 3 www.baidu.com>nul
EXIT
要是五次以后进入不了程序
可以在程序的最前面加上
if exist input.cde goto exit
作者: shmilyfriend     时间: 2010-7-10 12:12
版主辛苦了。。我還是沒有弄明白。。!
作者: DOSroot     时间: 2010-7-10 21:02
此帖转移自 DOS疑难解答 & 问题讨论 (解答室)

身为版主,更应以身作则遵守论坛相应规定
http://www.cn-dos.net/forum/viewthread.php?tid=46409
http://www.cn-dos.net/forum/viewthread.php?tid=46315

扣分予以提醒,望今后引起注意。

作者: doslike     时间: 2010-7-12 09:40
我以后一定注意
作者: doslike     时间: 2010-7-12 09:43
@echo off
if exist input.cde goto exit
title Easy Go!       %username%  - %date%  -  %time%!
color 7F
mode con cols=70 lines=15
:check
if exist c:\5.pwd goto exit
if exist c:\4.pwd echo 123>5.pwd
if exist c:\3.pwd echo 123>4.pwd
if exist c:\2.pwd echo 123>3.pwd
if exist c:\1.pwd echo 123>2.pwd
if not exist c:\1.pwd echo 123>1.pwd
echo Read carefully for the first time  
echo 1.If you need help please input 7!
echo 2.If you have some good suggestions
echo   can send mails to "shmilyfriend@sina.com" or shmilyfriend@126.com


echo Please input the number




:shuru
set /p i=i:
if "%i%"=="" goto shuru
if %i% GEQ 9 goto tishi




if "%i%"=="1" GOTO labsys
if "%i%"=="2" GOTO change_window
if "%i%"=="3" GOTO Infor_window
if "%i%"=="4" GOTO QQ
if "%i%"=="5" GOTO color ball
if "%i%"=="6" GOTO sina
if "%i%"=="7" GOTO help
if "%i%"=="8" GOTO 88


:tishi
echo wrong number! pls input again
GOTO shuru

:record
echo    %date% -%time% -%username% use %i% >>d:\test1.txt
exit

:color ball
start "" "D:\03.exe"
goto record
exit

:QQ
start "" "D:\program files\tencent\qq\bin\qq.exe"
goto record
exit

:help
echo 1 :labsys
echo 2:修改窗口  
echo 3:提示窗口
echo 4:QQ  
echo 5:彩球  
echo 6:Sina
echo 7:離開
echo 8:幫助。。。
goto shuru

:88
msg %username% best wishes and see you next time。。。
goto record
exit

:labsys
start "" "D:\桌面資料\tool\169-0327.exe"
goto record
exit

:change_window
start "" "D:\桌面資料\tool\修改窗口0324.exe"
goto record
exit

:Infor_window
start "" "D:\桌面資料\tool\提示窗口.exe"
goto record
exit

:sina
start "" "D:\Program Files\TheWorld 2.0\TheWorld.exe" "http://mail.sina.com.cn/"
goto record
exit
:exit
ECHO 123>input.cde
attrib +r +h .\input.cde
echo You cann't input the password!
echo Because you input FIFTH password were wrong.
echo There is any thing-wrong with the progam,
echo after 3 sec. progam EXIT!!
ping -n 3 www.baidu.com>nul
EXIT
作者: DOSroot     时间: 2010-7-14 18:56
我认从为“回收站”移到“其它操作系统综合讨论区”不太合适,移到“批处理”版块显然比较适合。
作者: doslike     时间: 2010-7-28 13:44
批处理板块也收win的?