Saturday, February 10, 2018

Start a Service in windows using script

Save the below lines of code in a .bat file. I am trying to start MySQL57 service if its not running already.


for /F "tokens=3 delims=: " %%H in ('sc query MySQL57 ^| findstr " STATE"') do ( if /I "%%H" NEQ "RUNNING" ( net start MySQL57 ) )