How to start and stop windows service using single batch file

echo off
set service=MyService
for /f "tokens=3" %%a in ('sc query "%service%" ^| find "STATE"') do (
 if %%a==4 goto running
 goto stopped
)
:stopped
sc start %service%
goto :eof
:running
goto :eof