【发布时间】:2021-07-18 20:32:26
【问题描述】:
谁能告诉我如何让errorlevel 停止取值1 或更大?我希望它只考虑确切的值。如果我选择 2,我希望它采用第二个选项。 现在,如果我选择“1”,它将执行 DLL 文件而不是 LOG 的选项。我尝试了不同的版本,例如: 如果错误级别为 1,尝试将括号与 else 等一起使用,但它们都不起作用。这段代码有什么问题?
@echo off
cls
choice /C 12 /M "dll or log?"
if %errorlevel%=="2" dir %1\*.dll >> %2.txt
echo DLL
goto end
if %errorlevel%=="1" dir %1\*.log >> %3.txt
echo LOG
goto end
:end
exit /b
【问题讨论】:
-
引号是比较的一部分,因此必须在两边都出现或没有......
标签: if-statement batch-file cmd errorlevel