我正在编写一个批处理脚本来解锁一些帐户(如果它们存在)并根据结果转到标签。
当前的脚本有效,有点。它只是没有最终到达正确的标签。我知道标签必须按正确的顺序排列,但我只是不明白这个顺序是什么以及如何正确检查错误级别。
@echo off
cls
echo -------------------
echo Unlocking Account0...
echo -------------------
pause
net user Account0 /active:yes
goto %ERRORLEVEL%
:0
cls
echo -------------------
echo Account0 unlocked successfully!
echo Press any key to reboot now.
echo -------------------
pause
goto reboot
:2
cls
echo -------------------
echo Account0 not found. Unlocking Account1...
echo -------------------
pause
net user Account1 /active:yes
if errorlevel 2 goto 3
if errorlevel 0 goto 0
:3
cls
echo -------------------
echo Account0 and Account1 not found!
echo Please make sure that one of these accounts exist.
echo You can use the command "net user <accounthere> /active:yes" to manually unlock an account.
echo -------------------
pause
goto END
:END
cls
echo NONE FOUND, EXIT SCRIPT.
:reboot
cls
echo ACCOUNT FOUND, REBOOT HERE
而已。没有什么花哨。它只是没有找到正确的标签。