1

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?

markfree
  • 59
  • 5
  • 1
    Your question is more 'how do I …', than 'can you assist me with a fix for …', and is therefore not really suited to StackOverflow. – Compo Dec 15 '20 at 16:01
  • My aim is to get some precious insights, tips or any feedback from our community. A tutorial would be pretentious, I guess. But I appreciate your feedback. Thanks. – markfree Dec 17 '20 at 12:08
  • This site provides assistance to fix a specific reproducible error with your provided code, given that the code was written to perform a certain task, and that task is failing to perform as written and intended. Your posted question is looking for research information, that is one or more stages before writing your code, testing it, and it exhibiting an issue which requires our assistance to fix. Your question is therefore not appropriate for this site and is off topic. Please take the [tour], and read [ask] and each of its linked pages, to learn more about the site you signed up to. – Compo Dec 17 '20 at 12:36
  • @Compo is question is perfectly legit. I am asking myself the same question and I have exactly the same use case. Maybe the formulation could be a bit more straight to the point but it is ok to use an example. – pepece Mar 02 '22 at 11:25
  • question can be marked as a duplicate https://stackoverflow.com/a/2874964/6193177 – pepece Mar 02 '22 at 11:43

0 Answers0