Liviu,
That seem to work well.
I put some pauses in it so I can see it as it works. Is there a way to >> push the disabled ones into a text file, then start disabled.txt
I want to stop those currently running, and disable them from restarting. Of course I will need to list AV services as to not disable them, but if they are any good, they don't allow that (which is a test I want)
So currently this code only stops those stoppable but does it disable all those not in the list?
This is why I was shooting for just stopping and disabling anything not in the list. I wouldn't use this on computers with specialized services of course.
By the way, thank you for your help. Please understand, these are the services I would be turning off anyway, just more automated.
Stopping services, restarting services(safemode)
Moderator: DosItHelp
-
- Posts: 20
- Joined: 25 May 2012 12:34
Re: Stopping services, restarting services(safemode)
Assuming you mean "stopped" rather than "disabled", yes, all you need to do is add a line "if exist disabled.txt del disabled.txt" before the top for loop, then right after "net stop" insert a line "echo %svcex%>>disabled.txt".crobertson wrote:Is there a way to >> push the disabled ones into a text file
crobertson wrote:then start disabled.txt
Code: Select all
for /f "delims=" %%x in (disabled.txt) do @echo net start "%%x"
Only stops, the disabling part popped up later in the thread. If you really have to do that, lookup "sc config start=".crobertson wrote:So currently this code only stops those stoppable but does it disable all those not in the list?
Just as a note, even the "turning off" part is not guaranteed to always work, and can't be made to work reliably using a simplistic batch+whitelist solution. For example, it is technically possible that the next millisecond after you "net stop" a service, another service which comes later in the alphabetical list (and has not been stopped yet) needs the first service and restarts it manually.crobertson wrote:Please understand, these are the services I would be turning off anyway, just more automated.
Liviu
-
- Posts: 20
- Joined: 25 May 2012 12:34
Re: Stopping services, restarting services(safemode)
To complete this topic, I created a batch that disables all but a few necessary services. It is similar to safe mode. It has been a great success and allows us to install programs to scan. An alternative we have found was a little utility that enabled services in safe mode to allow installations.
We also use a similar batch to disable multiple services that really increase the computers speed. Thanks all for the help.
We also use a similar batch to disable multiple services that really increase the computers speed. Thanks all for the help.