考虑以下批处理文件:
@echo off
set ORACLESERVER=ORAOP09
set ORACLEDB=OraDb11g_home1
set ORACLESERVICES.1 = OracleVssWriter%ORACLESERVER%
set ORACLESERVICES.2 = OracleDBConsole%ORACLESERVER%
set ORACLESERVICES.3 = Oracle%ORACLEDB%TNSListener
set ORACLESERVICES.4 = OracleService%ORACLESERVER%
AT > NUL
IF ERRORLEVEL 1 (
echo FATAL: THIS SCRIPT MUST BE RUN AS ADMINISTRATOR!
pause
exit
)
echo Stopping services...
FOR /F "tokens=2* delims=.=" %%A IN ('SET ORACLESERVICES.') DO sc stop %%B > NUL
FOR /F "tokens=2* delims=.=" %%A IN ('SET ORACLESERVICES.') DO call:check %%B
:check
sc query %1 | find /I "State" | find /I "STOPPED"
IF ERRORLEVEL 1 call:check %1
echo All services stopped successfully!
pause
exit
在第二个 FOR 语句中,当 ERRORLEVEL = 0 时,将运行文件的其余部分,而不是转到下一个 FOR 项。我怎样才能使这项工作按预期进行?
谢谢!