![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 21:31 |
47,812 topics / 349,917 posts / today 0 new / 48,274 members |
| DOS学习入门 & 精彩文章 (教学室) » What’s wrong with this batch file |
| Printable Version 1,033 / 2 |
| Floor1 xuan5272095 | Posted 2003-08-23 00:00 |
| 初级用户 Posts 3 Credits 113 | |
|
This is a *.bat file I wrote by following the example in a book, but it gives an error when I run it.
Please help me take a look @echo off choice /c:dme defrag,mem,end if errorlevel 3 goto defrag if errorlevel 2 goto mem if errotlevel 1 goto end :defrag c:\windows\defrag.exe goto end :mem mem goto end :end echo good bye After running it, choosing d or m is fine, but choosing e gives the result for choosing d |
|
| Floor2 willsort | Posted 2003-09-06 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re xuan5272095:
It's obviously an input error: if errotlevel 3 goto end -> if errorlevel 3 goto end |
|
| Floor3 iceboy | Posted 2003-09-06 00:00 |
| 银牌会员 Posts 512 Credits 1,681 | |
|
Make a choice: choice /c:dme defrag,mem,end (no problem)
Choose end (errorlevel 1) if errorlevel 3 goto defrag -- errorlevel is less than 3, skip if errorlevel 2 goto mem -- errorlevel is less than 2, skip if errotlevel 1 goto end -- invalid statement, skip and show an error message :defrag -- label, skip c:\windows\defrag.exe -- execute goto end -- go to the end That is why choosing e gives the result for choosing d Add one line: goto error
This can avoid errors caused by not finding choice.com (and if the BAT is written wrong, it will also show an error message) |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |