1.

Solve : Script to stop Windows services?

Answer»

This script provides the RESULT below.

Code: [Select]::Customize this list of services
SET Services2STOP=ALG BITS WZCSVC

FOR /f "Tokens=1,2 Delims=:" %%r IN ('"SC QUERY state= all"') DO (
IF /i "%%r"=="SERVICE_NAME" (
FOR %%f in (%Services2STOP%) DO (
IF /i " %%f"=="%%s" (
ECHO.SC STOP%%s
SC GETDISPLAYNAME %%s
)
)
)
)
Pause &EXIT
Code: [Select]SC STOP ALG
[SC] GetServiceDisplayName SUCCESS Name = Service de la PASSERELLE de la couche
Application
SC STOP BITS
[SC] GetServiceDisplayName SUCCESS Name = Service de transfert intelligent en a
rriÞre-plan
SC STOP WZCSVC
[SC] GetServiceDisplayName SUCCESS Name = CONFIGURATION automatique sans fil



1. How to avoid (not display) this: "[SC] GetServiceDisplayName SUCCESS Name = " ?
2. Which command is better to stop a service:
NET STOP service_name
SC STOP service_name
3. This script should be executed once or at each Windows startup ?
ThanksUnless I missed something, this script doesn't do a whole lot.

1. How to avoid (not display) this: "[SC] GetServiceDisplayName SUCCESS Name = " ?

Eliminate the SC GETDISPLAYNAME %%s line

2. Which command is better to stop a service:

SC communicates with both the Registry and Service Database

3. This script should be executed once or at each Windows startup ?

Try using SC CONFIG to change how a service starts up; To run at EVERY boot, put script in startup folder



Curious about something: why not use the services snapin (services.msc) and stop the services directly? It would only need be done once instead of every boot.

Just asking: I trust you researched these services to see check the consequences of turning them off.



Discussion

No Comment Found