All about Information Technology!

Check Status of Windows Service

To check if a local or a remote Windows service is running or not, create a batch file, name it for ex. check_service.bat

and paste the following code:

@echo off
sc \\localhost query Apache2.2 > service_status.txt
Find /i "RUNNING" service_status.txt >> service_status.txt
IF %errorlevel% == 0 (
	echo service is running
) ELSE (
	echo service is not running
)
@echo on
pause

, , , ,

Leave a Reply