How to check if a service is running via batch file and start it, if it is not running?
To check a service’s state, use sc query <SERVICE_NAME>. For if blocks in batch files, check the documentation. The following code will check the status of the service MyServiceName and start it if it is not running (the if block will be executed if the service is not running): for /F “tokens=3 delims=: ” %%H … Read more