Hi all,
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:
:begin
@echo off
sc start WinService01
if errorlevel 1 goto end
echo Success
:end
echo Failed
In this snippet when the service runs fine it will display Success, no problem. But when the service fails to run it will display Failed AND Success.
What am I missing? Or if you have a better script I'd appreciate it.
Thanks in advanced!
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:
:begin
@echo off
sc start WinService01
if errorlevel 1 goto end
echo Success
:end
echo Failed
In this snippet when the service runs fine it will display Success, no problem. But when the service fails to run it will display Failed AND Success.
What am I missing? Or if you have a better script I'd appreciate it.
Thanks in advanced!