Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch file which uses taskkill to stop several services. The commands look like this:

taskkill /s \\myServer /f /fi "Services eq MyService"

The problem is that each command takes a really long time (around 1 minute). Since there are several such commands, the batch file is really slow.

Is there any way to speed up taskkill?

share|improve this question

Try using sc stop instead of killing the service. It's a preferred method.

share|improve this answer
A service will try going through a normal service stop procedure, which can take a little while, but is always safer than a hard process kill. A process kill should only be used when absolutely necessary. – music2myear Sep 1 '11 at 22:09
OK but is sc any faster than taskkill? That was my real question. – JoelFan Sep 2 '11 at 15:25
Sorry, didn't mean to ignore that aspect of the question, but I really can't say for sure. I was hoping you'd test it and let us know. The answer to that question might be service specific. Nixphoe's method might help as long as there isn't a specific order that the services must be stopped. – pk. Sep 6 '11 at 13:06

In addition to what @pk said, if you must use taskkill, you could create one bat file for each task to kill, then create a bat file to call each batch file.

Would still be slow for each taskkill to finish, but they would run at the same time, speeding up your full script.

Should look something like this:

cmd /c c:\bat\killbatch1.bat
cmd /c c:\bat\killbatch2.bat
cmd /c c:\bat\killbatch3.bat
share|improve this answer

I tried switching to sc but it was also very slow. There is some underlying issue (possibly networking related?) but I haven't been able to find it.

I ended up moving the service stopping code to a .vbs script using WMI using the info here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.