Unfortunately, this command doesn't exist. The sc
can start and stop a service and it can query the status of a service (see this answer). But even when you query, you will only get "Service is running"; there is no way to tell how far the service got in its startup.
There are two workarounds:
- Sleep for a while
- Run a simple SQL command in a loop
The first approach will help but it won't completely solve the problem; when the server is under load, the startup can take longer.
For the second approach, use a loop which times out (pseudocode):
- Set counter to X
- Try to connect
- If connect succeeded, exit with success
- Decrement counter
- If counter <= 0 -> ERROR
- Sleep 1s
- Go to step 2
For additional safety, you could add a sc query
in there to make sure the service didn't fail.