Question : Checking service status with .bat file

Running Windows XP, I have three services whose status I want to automatically verify.  If the three services are running I simply want to proceed to the next line in the .bat file.  I tried piping text from sc.exe query to a variable but that didn't do anything.  Assume we have services name sc1, sc2 and sc3.

Thanks

Answer : Checking service status with .bat file

Could do something like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
@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
Random Solutions  
 
programming4us programming4us