找回密码
 加入
搜索
查看: 2477|回复: 10

服务优化的问题

[复制链接]
发表于 2008-10-4 18:31:53 | 显示全部楼层 |阅读模式
msgbox(1,"提示","开始优化系统服务!")
_RunDOS("sc config Alerter start= DISABLED")
_RunDOS("sc config ALG start= DISABLED")
_RunDOS("sc config AppMgmt start= DEMAND")
_RunDOS("sc config AudioSrv start= AUTO")
_RunDOS("sc config BITS start= DISABLED")
_RunDOS("sc config Browser start= DISABLED")
_RunDOS("sc config CiSvc start= DISABLED")
_RunDOS("sc config ClipSrv start= DISABLED")
_RunDOS("sc config COMSysApp start= DEMAND ")
_RunDOS("sc config CryptSvc start= DEMAND ")
_RunDOS("sc config DcomLaunch start= AUTO")
_RunDOS("sc config Dhcp start= DEMAND")
_RunDOS("sc config dmadmin start= DEMAND")
_RunDOS("sc config dmserver start= AUTO")
_RunDOS("sc config Dnscache start= DEMAND")
_RunDOS("sc config ERSvc start= DISABLED")
_RunDOS("sc config Eventlog start= AUTO")
_RunDOS("sc config EventSystem start= DEMAND")
_RunDOS("sc config helpsvc start= DISABLED")
_RunDOS("sc config HidServ start= DISABLED")
_RunDOS("sc config HTTPFilter start= DEMAND")
_RunDOS("sc config ImapiService start= DISABLED")
_RunDOS("sc config lanmanserver start= DISABLED")
_RunDOS("sc config lanmanworkstation start= AUTO")
_RunDOS("sc config LmHosts start= DISABLED")
_RunDOS("sc config Messenger start= DISABLED")
_RunDOS("sc config mnmsrvc start= DISABLED")
_RunDOS("sc config MSDTC start= AUTO")
_RunDOS("sc config MSIServer start= DEMAND")
_RunDOS("sc config NetDDE start= DISABLED")
_RunDOS("sc config NetDDEdsdm start= DISABLED")
_RunDOS("sc config Netlogon start= DISABLED")
_RunDOS("sc config Netman start= DEMAND ")
_RunDOS("sc config Nla start= DISABLED")
_RunDOS("sc config NtLmSsp start= DISABLED")
_RunDOS("sc config NtmsSvc start= DEMAND")
_RunDOS("sc config ose start= DEMAND")
_RunDOS("sc config PlugPlay start= AUTO")
_RunDOS("sc config PolicyAgent start= DEMAND")
_RunDOS("sc config ProtectedStorage start= AUTO")
_RunDOS("sc config RasAuto start= DEMAND")
_RunDOS("sc config RasMan start= DEMAND")
_RunDOS("sc config RDSessMgr start= DISABLED")
_RunDOS("sc config remoteAccess start= DISABLED")
_RunDOS("sc config remoteRegistry start= DISABLED")
_RunDOS("sc config RpcLocator start= DISABLED")
_RunDOS("sc config RpcSs start= AUTO")
_RunDOS("sc config SamSs start= AUTO")
_RunDOS("sc config SCardSvr start= DISABLED")
_RunDOS("sc config Schedule start= DISABLED")
_RunDOS("sc config seclogon start= AUTO")
_RunDOS("sc config SENS start= AUTO")
_RunDOS("sc config SharedAccess start= DEMAND")
_RunDOS("sc config ShellHWDetection start= AUTO")
_RunDOS("sc config Spooler start= DEMAND")
_RunDOS("sc config stisvc start= DEMAND")
_RunDOS("sc config swprv start= DISABLED")
_RunDOS("sc config SysmonLog start= DISABLED")
_RunDOS("sc config TapiSrv start= DEMAND")
_RunDOS("sc config TermService start= DISABLED")
_RunDOS("sc config Themes start= AUTO")
_RunDOS("sc config TrkWks start= DISABLED")
_RunDOS("sc config UMWdf start= DEMAND")
_RunDOS("sc config UPS start= DISABLED")
_RunDOS("sc config VSS start= DISABLED")
_RunDOS("sc config W32Time start= DISABLED")
_RunDOS("sc config WebClient start= DISABLED")
_RunDOS("sc config winmgmt start= AUTO")
_RunDOS("sc config WmdmPmSN start= DISABLED")
_RunDOS("sc config Wmi start= DEMAND")
_RunDOS("sc config WmiApSrv start= DISABLED")
_RunDOS("sc config wuauserv start= DISABLED")
_RunDOS("sc config WZCSVC start= DISABLED")
_RunDOS("sc config xmlprov start= DEMAND")
_RunDOS("sc config DcomLaunch start= AUTO")
_RunDOS("sc config FastUserSwitchingCompatibility start= DEMAND")
_RunDOS("sc config srservice start= DISABLED")
_RunDOS("sc config SSDPSRV start= DISABLED")
_RunDOS("sc config TlntSvr start= DISABLED")
_RunDOS("sc config upnphost start= DEMAND")
_RunDOS("sc config wscsvc start= DISABLED")
MsgBox(1,"提示","优化完毕")


运行不了  请教高手

[ 本帖最后由 鱼儿 于 2008-10-6 01:55 编辑 ]
发表于 2008-10-4 18:46:02 | 显示全部楼层
头文件都没有?如何运行?


#include <Process.au3>  
_RunDOS("sc config Alerter start= AUTO")

发表于 2008-10-4 18:48:27 | 显示全部楼层
还有上边的代码非常累赘,不容易维护。直接用数组,修改也简单。代码也简洁。
发表于 2008-10-4 18:52:48 | 显示全部楼层
...干嘛一定要通过命令行...
既然用autoit干嘛还要把写bat的习惯拿来?
sc其实就是sc.exe,后面是参数,直接调用不久可以了
 楼主| 发表于 2008-10-4 19:03:06 | 显示全部楼层
谢谢sanhen   解决了
用数组? 能写个例子看下吗?
发表于 2008-10-5 14:37:29 | 显示全部楼层
#include <WindowsConstants.au3>
Local $CCS = "HKLM\SYSTEM\CurrentControlSet\"
AutoSetServ()
Func AutoSetServ()
        For $i In _ArrayCreate("Alerter", "ALG", "BITS", "Browser", "CiSvc", "ClipSrv", "COMSysApp", "dmadmin", "dmserver", "Dnscache", "ERSvc", "EventSystem", "helpsvc", "HidServ", "ImapiService", "lanmanserver")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStop(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "4")
                EndIf
        Next
        For $i In _ArrayCreate("Messenger", "mnmsrvc", "MSDTC", "NetDDE", "NetDDEdsdm", "Netlogon", "NtLmSsp", "Nvsvc", "Ose", "RDSessMgr", "RemoteAccess", "RemoteRegistry", "SCardSvr", "Schedule", "seclogon", "SENS", "SharedAccess")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStop(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "4")
                EndIf
        Next
        For $i In _ArrayCreate("Stisvc", "Swprv", "SysmonLog", "TermService", "TlntSvr", "TrkWks", "UMWdf", "upnphost", "UPS", "VSS", "W32Time", "WebClient", "WmdmPmSN", "WmiApSrv", "wuauserv", "WMConnectCDS", "WMPNetworkSvc", "WZCSVC")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStop(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "4")
                EndIf
        Next
        For $i In _ArrayCreate("LmHosts", "SSDPSRV", "Wmi", "RpcLocator", "winmgmt", "Spooler", "FastUserSwitchingCompatibility", "lanmanworkstation", "ShellHWDetection", "srservice", "wscsvc", "xmlprov")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStop(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "4")
                EndIf
        Next
        For $i In _ArrayCreate("AppMgmt", "CryptSvc", "HTTPFilter", "MSIServer", "NtmsSvc", "RasAuto", "RasMan")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStop(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "3")
                EndIf
        Next
        For $i In _ArrayCreate("AudioSrv", "Eventlog", "Netman", "Nla", "PlugPlay", "PolicyAgent", "ProtectedStorage", "RpcSs", "SamSs", "TapiSrv", "Themes", "DcomLaunch", "Dhcp")
                If ServiceExists(@ComputerName, $i) = 1 Then
                        ServiceStart(@ComputerName, $i)
                        RegWrite($CCS & "\Services\" & $i, "start", "REG_DWORD", "2")
                EndIf
        Next
              EnvUpdate()
        MsgBox(0, "完成", "服务设置完成!")
EndFunc   ;==>AutoSetServ

[ 本帖最后由 netegg 于 2008-10-5 14:43 编辑 ]
发表于 2008-10-5 14:45:09 | 显示全部楼层
没看你怎么设置的服务,我把我的代码直接贴上了,4是禁用,3是手动,2是自动
发表于 2008-10-5 17:08:32 | 显示全部楼层
原帖由 netegg 于 2008-10-5 14:37 发表
#include
Local $CCS = "HKLM\SYSTEM\CurrentControlSet\"
AutoSetServ()
Func AutoSetServ()
        For $i In _ArrayCreate("Alerter", "ALG", "BITS", "Browser", "CiSvc", "ClipSrv", "COMSysApp", "dmadmin", "d ...

#include <Array.au3>......
发表于 2012-1-7 13:31:30 | 显示全部楼层
学习..........................
发表于 2012-4-13 22:46:00 | 显示全部楼层
看来数组很重要
发表于 2012-5-11 14:55:22 | 显示全部楼层
感觉方法不太好,我也建议用数组来完成
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-19 03:39 , Processed in 0.078819 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表