I'm trying to restart some services using a simple batch file like this:
sc stop "service 1"
sc stop "service 2"
timeout /T 5
tskill "java" /A /V
tskill "service 1 proc" /A /V
tskill "service 2 proc" /A /V
timeout /T 5
sc start "service 2"
sc start "service 1"
Basically, it stops some services, kill the processes if the services "stop pending" and start them again.
If SC takes some time to finish a service, it will not wait until the task finishes before going to the next command.
I don't wish to input a lot of "timeouts" in between commands, just give SC some time to work until it finishes its task.
Is there a way to set SC.exe to finish its task, or wait a timeout, before going to the next command?