@echo off echo Date-Time >> ServiceStart.log date /T >> ServiceStart.log time /T >> ServiceStart.log rem List of controlled services set list=ServiceUniversalBBT^ ServiceUpdateFirmwareBBT^ ServiceTCPLoger^ scm-server^ postgresql-9.5^ pgAgent^ MySQL^ FirebirdServerDefaultInstance (for %%a in (%list%) do ( echo Check: %%a CALL :StartService %%a )) goto :end rem Checks whether the service is running and starts it if it is stopped. :StartService echo Check: %1 >> ServiceStart.log for /F "tokens=4" %%i in ('sc query %1') DO if [%%i]==[STOPPED] ( sc query %1 >> ServiceStart.log sc start %1 >> ServiceStart.log ) exit /b :end