本帖最后由 zhuqingedu 于 2010-9-28 20:50 编辑
skyfree的《XP定制不完全攻略》里,分享了一个自动优化服务的脚本,很是实用,脚本内容如下,我现在有个需求,就是希望用户在运行这个脚本之后,先弹出一个窗口,提示:“运行此程序前,请确定已经在360安全卫士里将禁用的服务全部恢复。”然后点击“确定”按钮开始执行脚本,点击“取消”则关闭脚本。(如果不先在360安全卫士里将禁用的服务恢复的话,即使在services.msc里手动把服务设置成自动启动,重启后还是会被360强行禁用的。)因为对AU3一点都不懂,所以希望哪位朋友可以帮忙改改,呵呵。
对了,还有个问题请教下,这个脚本里声明$DemandServName[]和$DemandServ[]时好像都是说有24个变量,但是这两个数组都只赋值了21个,不知道是什么原因呀。Dim $DisabledServ[31],$DemandServ[24],$AutoServ[29]
Dim $DisabledServName[31],$DemandServName[24],$AutoServName[29]
Dim $i,$t
$t=0
;$Disabled
$DisabledServ[1] = "Alerter"
$DisabledServ[2] = "ClipSrv"
$DisabledServ[3] = "TrkWks"
$DisabledServ[4] = "MSDTC"
$DisabledServ[5] = "ERSvc"
$DisabledServ[6] = "FastUserSwitchingCompatibility"
$DisabledServ[7] = "helpsvc"
$DisabledServ[8] = "HidServ"
$DisabledServ[9] = "ImapiService"
$DisabledServ[10] = "CiSvc"
$DisabledServ[11] = "Messenger"
$DisabledServ[12] = "SwPrv"
$DisabledServ[13] = "mnmsrvc"
$DisabledServ[14] = "NetDDE"
$DisabledServ[15] = "NetDDEdsdm"
$DisabledServ[16] = "RSVP"
$DisabledServ[17] = "RemoteRegistry"
$DisabledServ[18] = "NtmsSvc"
$DisabledServ[19] = "RemoteAccess"
$DisabledServ[20] = "seclogon"
$DisabledServ[21] = "wscsvc"
$DisabledServ[22] = "ShellHWDetection"
$DisabledServ[23] = "SENS"
$DisabledServ[24] = "srservice"
$DisabledServ[25] = "TlntSvr"
$DisabledServ[26] = "TermService"
$DisabledServ[27] = "UPS"
$DisabledServ[28] = "VSS"
$DisabledServ[29] = "WebClient"
$DisabledServ[30] = "W32Time"
$DisabledServName[1] = "Alerter"
$DisabledServName[2] = "ClipBook"
$DisabledServName[3] = "Distributed Link Tracking Client"
$DisabledServName[4] = "Distributed Transaction Coordinator"
$DisabledServName[5] = "Error Reporting Service"
$DisabledServName[6] = "Fast User Switching Compatibility"
$DisabledServName[7] = "Help and Support"
$DisabledServName[8] = "Human Interface Device Access"
$DisabledServName[9] = "IMAPI CD-Burning COM Service"
$DisabledServName[10] = "Indexing Service"
$DisabledServName[11] = "Messenger"
$DisabledServName[12] = "MS Software Shadow Copy Provider"
$DisabledServName[13] = "NetMeeting Remote Desktop Sharing"
$DisabledServName[14] = "Network DDE"
$DisabledServName[15] = "Network DDE DSDM"
$DisabledServName[16] = "QoS RSVP"
$DisabledServName[17] = "Remote Registry"
$DisabledServName[18] = "Removable Storage"
$DisabledServName[19] = "Routing and Remote Access"
$DisabledServName[20] = "Secondary Logon"
$DisabledServName[21] = "Security Center"
$DisabledServName[22] = "Shell Hardware Detection"
$DisabledServName[23] = "System Event Notification"
$DisabledServName[24] = "System Restore Service"
$DisabledServName[25] = "Telnet"
$DisabledServName[26] = "Terminal Services"
$DisabledServName[27] = "Uninterruptible Power Supply"
$DisabledServName[28] = "Volume Shadow Copy"
$DisabledServName[29] = "WebClient"
$DisabledServName[30] = "Windows Time"
;$Demand
$DemandServ[1] = "AppMgmt"
$DemandServ[2] = "COMSysApp"
$DemandServ[3] = "HTTPFilter"
$DemandServ[4] = "dmadmin"
$DemandServ[5] = "Netlogon"
$DemandServ[6] = "Netman"
$DemandServ[7] = "xmlprov"
$DemandServ[8] = "NtLmSsp"
$DemandServ[9] = "SysmonLog"
$DemandServ[10] = "WmdmPmSN"
$DemandServ[11] = "RasAuto"
$DemandServ[12] = "RasMan"
$DemandServ[13] = "RDSessMgr"
$DemandServ[14] = "RpcLocator"
$DemandServ[15] = "SCardSvr"
$DemandServ[16] = "SSDPSRV"
$DemandServ[17] = "TapiSrv"
$DemandServ[18] = "stisvc"
$DemandServ[19] = "MSIServer"
$DemandServ[20] = "Wmi"
$DemandServ[21] = "WmiApSrv"
;$DemandServ[] = "WudfSvc"
;$DemandServ[] = "WMPNetworkSvc"
$DemandServName[1] = "Application Management"
$DemandServName[2] = "COM+ System Application"
$DemandServName[3] = "HTTP SSL"
$DemandServName[4] = "Logical Disk Manager Administrative Service"
$DemandServName[5] = "Net Logon"
$DemandServName[6] = "Network Connections"
$DemandServName[7] = "Network Provisioning Service"
$DemandServName[8] = "NT LM Security Support Provider"
$DemandServName[9] = "Performance Logs and Alerts"
$DemandServName[10] = "Portable Media Serial Number Service"
$DemandServName[11] = "Remote Access Auto Connection Manager"
$DemandServName[12] = "Remote Access Connection Manager"
$DemandServName[13] = "Remote Desktop Help Session Manager"
$DemandServName[14] = "Remote Procedure Call (RPC) Locator"
$DemandServName[15] = "Smart Card"
$DemandServName[16] = "SSDP Discovery Service"
$DemandServName[17] = "Telephony"
$DemandServName[18] = "Windows Image Acquisition (WIA)"
$DemandServName[19] = "Windows Installer"
$DemandServName[20] = "Windows Management Instrumentation Driver Extensions"
$DemandServName[21] = "WMI Performance Adapter"
;$Auto
$AutoServ[1] = "ALG"
$AutoServ[2] = "wuauserv"
$AutoServ[3] = "BITS"
$AutoServ[4] = "EventSystem"
$AutoServ[5] = "Browser"
$AutoServ[6] = "CryptSvc"
$AutoServ[7] = "DcomLaunch"
$AutoServ[8] = "Dhcp"
$AutoServ[9] = "Dnscache"
$AutoServ[10] = "Eventlog"
$AutoServ[11] = "PolicyAgent"
$AutoServ[12] = "dmserver"
$AutoServ[13] = "Nla"
$AutoServ[14] = "PlugPlay"
$AutoServ[15] = "Spooler"
$AutoServ[16] = "ProtectedStorage"
$AutoServ[17] = "RpcSs"
$AutoServ[18] = "SamSs"
$AutoServ[19] = "lanmanserver"
$AutoServ[20] = "Schedule"
$AutoServ[21] = "LmHosts"
$AutoServ[22] = "Themes"
$AutoServ[23] = "upnphost"
$AutoServ[24] = "AudioSrv"
$AutoServ[25] = "SharedAccess"
$AutoServ[26] = "winmgmt"
$AutoServ[27] = "WZCSVC"
$AutoServ[28] = "lanmanworkstation"
$AutoServName[1] = "Application Layer Gateway Service"
$AutoServName[2] = "Automatic Updates"
$AutoServName[3] = "Background Intelligent Transfer Service"
$AutoServName[4] = "COM+ Event System"
$AutoServName[5] = "Computer Browser"
$AutoServName[6] = "Cryptographic Services"
$AutoServName[7] = "DCOM Server Process Launcher"
$AutoServName[8] = "DHCP Client"
$AutoServName[9] = "DNS Client"
$AutoServName[10] = "Event Log"
$AutoServName[11] = "IPSEC Services"
$AutoServName[12] = "Logical Disk Manager"
$AutoServName[13] = "Network Location Awareness (NLA)"
$AutoServName[14] = "Plug and Play"
$AutoServName[15] = "Print Spooler"
$AutoServName[16] = "Protected Storage"
$AutoServName[17] = "Remote Procedure Call (RPC)"
$AutoServName[18] = "Security Accounts Manager"
$AutoServName[19] = "Server"
$AutoServName[20] = "Task Scheduler"
$AutoServName[21] = "TCP/IP NetBIOS Helper"
$AutoServName[22] = "Themes"
$AutoServName[23] = "Universal Plug and Play Device Host"
$AutoServName[24] = "Windows Audio"
$AutoServName[25] = "Windows Firewall/Internet Connection Sharing (ICS)"
$AutoServName[26] = "Windows Management Instrumentation"
$AutoServName[27] = "Wireless Zero Configuration"
$AutoServName[28] = "Workstation"
For $i=1 To 30
ToolTip(@CR&" 正在将如下服务调整为“禁用”: " & @CRLF & " " & $DisabledServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc config " & $DisabledServ[$i] & " start= disabled","",@SW_HIDE)
Sleep($t)
ToolTip(@CR&" 正在停用: " & @CRLF & " " & $DisabledServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc stop " & $DisabledServ[$i],"",@SW_HIDE)
Sleep($t)
Next
For $i=1 To 21
ToolTip(@CR&" 正在将如下服务调整为“手动”: " & @CRLF & " " & $DemandServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc config " & $DemandServ[$i] & " start= demand","",@SW_HIDE)
Sleep($t)
If $i=6 Or $i=12 Or $i=16 Or $i=17 Then
ToolTip(@CR&" 正在启用: " & @CRLF & " " & $DemandServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc start " & $DemandServ[$i],"",@SW_HIDE)
Sleep($t)
Else
ToolTip(@CR&" 正在停用: " & @CRLF & " " & $DemandServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc stop " & $DemandServ[$i],"",@SW_HIDE)
Sleep($t)
EndIf
Next
For $i=1 To 28
ToolTip(@CR&" 正在将如下服务调整为“自动”: " & @CRLF & " " & $AutoServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc config " & $AutoServ[$i] & " start= auto","",@SW_HIDE)
Sleep($t)
ToolTip(@CR&" 正在启用: " & @CRLF & " " & $AutoServName[$i] & " " & @CR, @DesktopWidth-260, @DesktopHeight-120)
RunWait("sc start " & $AutoServ[$i],"",@SW_HIDE)
Sleep($t)
Next
ToolTip(@CR&" 服务优化完成! " & @CR, @DesktopWidth-260, @DesktopHeight-120)
Sleep(3000)
|