我可能在这里很愚蠢,但我根本无法弄清楚我拥有的这段批处理代码的奇怪行为。
所以我有以下代码:
@echo off
set exitval=0
:selectdir
echo Type the name of the folder where the software is installed (or drag and
echo drop the folder here):
set /p sdir=
set sdir=%sdir:"=%
echo.
if not exist "%sdir%\Lib\Plugins" (
echo The plugins directory does not exist! Try again ^(y/N^)^?
set /p c=
if "%c%" == "y" goto selectdir
goto exitscript
)
:exitscript
pause
exit /b %exitval%
至少可以说,这并没有表现出一致的行为:
D:\Development>test.cmd
Type the name of the folder where the software is installed (or drag and
drop the folder here):
C:\xyz
The plugins directory does not exist! Try again (y/N)?
y
Press any key to continue . . .
D:\Development>test.cmd
Type the name of the folder where the software is installed (or drag and
drop the folder here):
C:\xyz
The plugins directory does not exist! Try again (y/N)?
n
Type the name of the folder where the software is installed (or drag and
drop the folder here):
C:\xyz
The plugins directory does not exist! Try again (y/N)?
n
Press any key to continue . . .
上面的代码有什么问题?为什么它不能始终如一地工作?