批处理利用sc禁用和启用服务
sc config 服务名称 start= auto(自动)
sc config 服务名称 start= demand(手动)
sc config 服务名称 start= disabled(禁用)
然后配合 net start 服务名称或者 net stop 服务名称 来使用
例子:
sc config shellhwdetection start= disabled 禁用shellhwdetection服务。
sc config shellhwdetection start= auto 设置shellhwdetection服务自动启动。
sc config shellhwdetection start= demand 设置shellhwdetection服务手动启动。
sc start shellhwdetection 启动shellhwdetection服务。
sc stop shellhwdetection 停止shellhwdetection服务。
sc delete shellhwdetection 删除shellhwdetection服务。
sc create Tomcat binPath= F:\apache-tomcat\bin\startup.bat start= auto 添加Tomcat服务。
sc config MSSQL$SQLEXPRESS start= auto 设置SQL Server (SQLEXPRESS)服务自动启动
sc config MSSQL$SQLEXPRESS start= demand 设置SQL Server (SQLEXPRESS)服务手动启动
sc config MSSQL$SQLEXPRESS start= disabled 禁用SQL Server (SQLEXPRESS)服务
net start "SQL Server (SQLEXPRESS)" 启动SQL Server (SQLEXPRESS)服务
net stop "SQL Server (SQLEXPRESS)" 停止SQL Server (SQLEXPRESS)服务
net pause "SQL Server (SQLEXPRESS)" 暂停SQL Server (SQLEXPRESS)服务
(如果服务名由两个或多个单词组成,必须用引号把该服务名圈起来,
如:sc config "ECShop httpd" start= demand)
sc config MSISerer start= demand & net start "Windows Installer"
意思是:
将 Windows Installer 服务设置为手动并启动该服务(Windows Installer的真实服务名是MSISerer)
注:
★★
1)服务名不一定是你在服务面板看到的那个名。
例如,你要打开被禁用的telnet服务,sc config telnet start= auto,
会报错:[SC] OpenService FAILED 1060,因为telnet的服务名不是telnet而是tlntsvr,
改为sc config tlntsvr start= auto 就OK了,
在服务里查看telnet服务的属性,在服务名上点击右键→属性,弹出的框中最上面可看到真正的服务名,
即命令中的服务名。
2)start= 后面有一个空格,如果不加这个空格,命令就无法执行,而且连错误提示也没有, 等号后加一个空格就好了.
举例:
@echo 禁用错误报告
sc config ERSvc start= DISABLED
net stop ERSvc
@echo 禁用系统帮助
sc config helpsvc start= DISABLED
net stop helpsvc
@echo 禁用打印后台
sc config Spooler start= DISABLED
net stop Spooler
@echo 禁用远程注册表
sc config RemoteRegistry start= DISABLED
net stop RemoteRegistry
@echo 禁用系统时间同步
sc config W32Time start= DISABLED
net stop W32Time
@echo 禁用无线网卡
sc config WZCSVC start= DISABLED
net stop WZCSVC
示例一:
@echo off rem echo (备注: 自动:auto 手动启动:demand 禁用:disabled ) sc config knbcenter start=disabled sc config PPTVService start=disabled sc config 360rp start=disabled sc config BFAssistantSvc start=disabled (net stop knbcenter)&(net stop PPTVService)&(net stop 360rp)&(net stop BFAssistantSvc) echo 已禁用服务:猎豹浏览器安全中心、PPTVService、360rp、BFAssistantSvc.. echo 选择要开启的服务: echo. echo 0 全部 echo 1 猎豹浏览器安全中心 echo 2 PPTVService echo 3 360杀毒实时防护 echo 4 BFAssistantSvc echo. set/p var=请选择要开启的服务序号: if %var%==0 (net start knbcenter)&(net start PPTVService)&(net start 360rp)&(net start BFAssistantSvc) if %var%==1 net start knbcenter if %var%==2 net start PPTVService if %var%==3 net start 360rp if %var%==4 net start BFAssistantSvc pause
示例二:
@echo off echo 服务优化正在处理,请稍等...... @echo @pause sc config ALG start= DEMAND sc config AppMgmt start= DEMAND sc config AudioEndpointBuilder start= AUTO sc config Audiosrv start= AUTO sc config BFE start= AUTO sc config BITS start= AUTO sc config Browser start= AUTO sc config CertPropSvc start= DEMAND sc config clr_optimization_v2.0.50727_32 start= DEMAND sc config COMSysApp start= DEMAND sc config CryptSvc start= AUTO sc config DcomLaunch start= AUTO sc config Dhcp start= AUTO sc config Dnscache start= AUTO sc config dot3svc start= DEMAND sc config EapHost start= DEMAND sc config EventSystem start= AUTO sc config fdPHost start= DEMAND sc config FDResPub start= DEMAND sc config FontCache3.0.0.0 start= DEMAND sc config gpsvc start= AUTO sc config hidserv start= DEMAND sc config hkmsvc start= DEMAND sc config idsvc start= DEMAND sc config IKEEXT start= AUTO sc config IPBusEnum start= DEMAND sc config KeyIso start= DEMAND sc config LanmanServer start= AUTO sc config LanmanWorkstation start= AUTO sc config lltdsvc start= DEMAND sc config lmhosts start= AUTO sc config MMCSS start= AUTO sc config MpsSvc start= AUTO sc config msiserver start= DEMAND sc config napagent start= DEMAND sc config Netlogon start= DEMAND sc config Netman start= DEMAND sc config netprofm start= AUTO sc config NetTcpPortSharing start= DISABLED sc config NlaSvc start= AUTO sc config NOD32krn start= AUTO sc config nsi start= AUTO sc config PlugPlay start= AUTO sc config ProfSvc start= AUTO sc config RasAuto start= DEMAND sc config RasMan start= DEMAND sc config RemoteAccess start= DISABLED sc config RpcLocator start= DEMAND sc config RpcSs start= AUTO sc config SamSs start= AUTO sc config SCardSvr start= DEMAND sc config SCPolicySvc start= DEMAND sc config SENS start= AUTO sc config SharedAccess start= DISABLED sc config ShellHWDetection start= AUTO sc config slsvc start= AUTO sc config SLUINotify start= DEMAND sc config SNMPTRAP start= DEMAND sc config SSDPSRV start= DEMAND sc config SstpSvc start= DEMAND sc config SysMain start= AUTO sc config TapiSrv start= DEMAND sc config TBS start= AUTO sc config Themes start= AUTO sc config THREADORDER start= DEMAND sc config TrustedInstaller start= DEMAND sc config upnphost start= DEMAND sc config UxSms start= AUTO sc config vds start= DEMAND sc config W32Time start= AUTO sc config wcncsvc start= DEMAND sc config WcsPlugInService start= DEMAND sc config WinHttpAutoProxySvc start= DEMAND sc config Winmgmt start= AUTO sc config Wlansvc start= DEMAND sc config wmiApSrv start= DEMAND sc config WMPNetworkSvc start= DEMAND sc config wscsvc start= AUTO sc config wuauserv start= AUTO sc config wudfsvc start= DEMAND @pause echo. echo.&echo 优化完成!任意键退出 echo. & pause>nul
评论