I'm writing this batch script to start/stop some windows services using a combination of net start/stop and sc.exe. Now I need to do some verification on it, command 2 can only run when command 1 runs successfully. So let's say I issue
sc start WinService01
If this service starts successfully it should run WinService02. If it doesn't run then goto WinService05 or something like that.
I've played around with:
Expand|Select|Wrap|Line Numbers
- :begin
- @echo off
- sc start WinService01
- if errorlevel 1 goto end
- echo Success
- :end
- echo Failed
What am I missing? Or if you have a better script I'd appreciate it.
Thanks in advanced!