Check if service is running

Written by Leif Stenfeldt. Posted in Dos, Programmering

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
sc query "%~1"|findstr "STATE.*:.*4.*RUNNING" >NUL
IF ERRORLEVEL 1 (
ECHO service %1 is stopped
goto :end
)
echo Service %1 is running
:end
EXIT /b
1536 views

Leave a comment