呼び出されたループでバッチ ファイルを完全に停止するにはどうすればよいですか?
exit /bバッチ ファイル全体ではなく、単に :label ループを終了するだけですが、bareはバッチ ファイルと親の CMD シェルを終了しますが、これは望ましくありませんexit。
@echo off
call :check_ntauth
REM if check fails, the next lines should not execute
echo. ...About to "rmdir /q/s %temp%\*"
goto :eof
:check_ntauth
  if not `whoami` == "nt authority\system" goto :not_sys_account
  goto :eof
:not_sys_account
  echo. &echo. Error: must be run as "nt authority\system" user. &echo.
  exit /b
  echo. As desired, this line is never executed.
結果:
d:\temp>whoami
mydomain\matt
d:\temp>break-loop-test.bat
 Error: must be run as "nt authority\system" user.
 ...About to "rmdir /q/s d:\temp\systmp\*"     <--- shouldn't be seen!