0

Im trying to create a .bat that stops all unnecessary services, but theres so many that it takes a while to finish, because as one service is stopping the rest have to wait for it to finish, is there any way to stop them all simultaneously without running seperate .bats for each service? windows 7

0

You can run asynchronous commands using start.

Example:

@start /b cmd /c net stop servicename1
@start /b cmd /c net stop servicename2
@start /b cmd /c net stop servicename3
@start /b cmd /c net stop servicename4
  • Wow thanks for the quick answer this is my first time asking here. Can you explain what the /b /c do? Thanks – PolisP May 3 '19 at 19:24
  • Sure. /b runs the following command in the same window so you don't get a bunch of them and /c executes the string following it and then terminates.So in this example we are starting a new command prompt instance without opening a new window and then sending the command net stop service and then telling it to terminate that instance it just opened when the command completes. Hope that helps. – Narzard May 3 '19 at 19:39
  • Theres a little problem, the list of services that I chose to stop is extensive, about 120, (theyre all default windows 7 services). The .bat that I made, stops them 4 times, so I copied the 120 @start /b cmd /c net stop "service" and made 4 lists of them to stop because some of them would still run after 1 list that tells them to stop, but the problem with that is the processess in the task manager goes from 21 up to 600 when I run the bat that ends everything and the cpu usage goes up to 60 on each of the 4 cores, (has no effect on gaming, no lag spikes) but I want to run this on a... – PolisP May 6 '19 at 21:02
  • ...schedule while Im gaming and it causes the cpu usage to go up, is there any way to fix the 600 processess in the task manager caused by this and is there any other trick to do this? – PolisP May 6 '19 at 21:03
  • Unfortunately not. Each line of this starts it's own cmd instance at the same time. Overall, it should be relatively lightweight on your system. Your best bet would be to make, lets say, 4 of these bats each with different entries. Use task scheduler to start each bat staggered and then rerun them every 2 minutes or so. IE bat1 kills 30 processes and starts at 9am, recurring every 4 minutes, Bat2 kills a different 30 and starts at 9:01am, recurring every 4 mins, etc. Really, the best way, since you already have a list of the services to stop, would be to write a powershell that checked each – Narzard May 7 '19 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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