我试图让用户选择使用默认目录,或者使用他们自己的目录作为变量%1
。这是我所拥有的:
if ("%1"=="default") {set %1=C:\TestExecution\test}
set source=%1
IF NOT EXIST "%source%" goto error3
goto end
:error3
echo.
echo Error: Invalid Path
echo %source%
goto end
:end
尝试使用 cmd 对其进行测试时,结果如下:
c:\TestExecution>test.bat default 10.42.232.245
Error: Invalid Path
default
如果有人知道正确的语法并且可以帮助一个新手,那将不胜感激。