@echo off
setlocal enabledelayedexpansion
for %%a in (sc1, sc2, sc3) do call :GETSRVSTAT "%%a"&if /i not "!status!"=="Running" goto :EOF
echo All services are running...
goto :EOF
:GETSRVSTAT
set status=
for /f "tokens=4" %%a in ('sc query "%~1" 2^>NUL^|findstr STATE') do set status=%%a
goto :EOF
|