我编写一个小的扫描有没有闪存的批处理时,用IF--ELSE时,老出现"ELSE既不是DOS内部命令,也不是可执行文件"的出错提示.
if exist h:\nul copy .........
else msg......
if exist h:\nul copy .........
else msg......
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
The ELSE clause must occur on the same line as the command after the IF. For
example:
IF EXIST filename. (
del filename.
) ELSE (
echo filename. missing.
)
@echo off
rem if...else...实例应用:判断输入数字的区域
:set
cls&set /p num=请输入0-50间的数字:
echo %num%|findstr "">nul&&goto wrong
if "%num: =%" gtr "50" goto wrong
for %%i in (10 20 30 40 50) do if %%i equ %num% cls&echo %num%=%%i&pause>nul&goto :eof
if %num% lss 10 (
cls&echo %num%^<10
) else (
if %num% lss 20 (
cls&echo 10^<%num%^<20
) else (
if %num% lss 30 (
cls&echo 20^<%num%^<30
) else (
if %num% lss 40 (
cls&echo 30^<%num%^<40
) else (
cls&echo 40^<%num%^<50
))))
pause>nul&goto :eof
:wrong
cls&echo 请正确输入!&&ping /n 2 127.1>nul&&goto set