Skip to content

Instantly share code, notes, and snippets.

@jovib
Created March 3, 2017 14:26
Show Gist options
  • Select an option

  • Save jovib/49922cd1ecb29f0090146893d4beb150 to your computer and use it in GitHub Desktop.

Select an option

Save jovib/49922cd1ecb29f0090146893d4beb150 to your computer and use it in GitHub Desktop.
Check if Windows service is running via batch file and start it, if it is not running.
for /F "tokens=3 delims=: " %%H in ('sc query "<service_name>" ^| findstr " ESTATE"') do (
if /I "%%H" NEQ "RUNNING" (
net start "<service_name>"
) else (
echo All stable.
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment