1.

Solve : Help needed with 'NET START'?

Answer»

I need to write a bat SCRIPT which starts 3 services in a predefined order and if any of these services doesn't start PROPERLY then script should terminate WITHOUT TRYING to start services below it.

For Example: let there be 3 services ServiceA ServiceB, ServiceC.
First ServiceA should be started then ServiceB and then ServiceC.
If ServiceA doesnt start properly then script should terminate without starting ServiceB aand ServiceC. And also if ServiceB fails then it should not start ServiceB but also stop already started ServiceA.

Please help me in this.

Thanks in advance.

~Gaurav
[link removed - please don't ADVERTISE]
Something like this might work:

Code: [Select]@echo off
net start serviceA
if errorlevel 1 goto :eof
net start serviceB
if errorlevel 1 (
net stop serviceA
goto :eof
)
net start serviceC
if errorlevel 1 (
net stop serviceA
net stop serviceB
goto :eof
)

This might work with || and && but I didn't have any services lying around waiting to be started, so you'll have to do the testing.



Discussion

No Comment Found