找回密码
 加入
搜索
查看: 6878|回复: 14

[AU3基础] [已解决]关于系统服务优化脚本的修改

 火.. [复制链接]
发表于 2010-9-27 23:40:26 | 显示全部楼层 |阅读模式
本帖最后由 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)

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-9-28 04:46:56 | 显示全部楼层
脚本做成这样不如用批处理了
 楼主| 发表于 2010-9-28 09:10:45 | 显示全部楼层
批处理的话会有问题,比如某些服务已经启动了,如果再用批处理去启动或者某些服务已经停止了,如果再用批处理去停止的话就会收到一个错误提示:
[SC] StartService 失败 1056:服务的实例已在运行中。
[SC] ControlService 失败 1062:服务尚未启动。
如果中途遇到错误还会中断,这种错误提示会使用户产生不安,而且批处理的体验也没有脚本编译成EXE后的体验好。
发表于 2010-9-28 10:24:29 | 显示全部楼层
$scr = MsgBox(1, "", "是继续,否关闭!")
If $scr = 1 Then
        MsgBox(0, "", "只是个举例!")
Else
        Exit
EndIf

评分

参与人数 1金钱 +15 收起 理由
afan + 15

查看全部评分

发表于 2010-9-28 10:27:45 | 显示全部楼层
回复 3# zhuqingedu

你这样操作了,该错还是错
 楼主| 发表于 2010-9-28 12:17:07 | 显示全部楼层
回复 4# shenrenba

谢谢shenrenba ,我的问题已经解决了,呵呵。
 楼主| 发表于 2010-9-28 12:17:56 | 显示全部楼层
回复  zhuqingedu

你这样操作了,该错还是错
netegg 发表于 2010-9-28 10:27


呵呵,建议这位朋友可以把优化服务的脚本和批处理分别在同一台机器上重复运行,就知道哪个会出错了。
发表于 2010-9-28 15:43:02 | 显示全部楼层
回复 7# zhuqingedu
我不用外部文件操作服务
发表于 2010-9-28 16:26:13 | 显示全部楼层
楼主,在天空论坛我已经回复你了!你去看看吧!
如果已经解决了问题,请修改标题为[已解决],谢谢!
 楼主| 发表于 2010-9-28 19:23:55 | 显示全部楼层
楼主,在天空论坛我已经回复你了!你去看看吧!
如果已经解决了问题,请修改标题为[已解决],谢谢!
hzxymkb 发表于 2010-9-28 16:26


呵呵,原来天空论坛的那个热心朋友就是你呀,真是太感谢你了,我这就去修改标题。
发表于 2010-9-28 20:47:23 | 显示全部楼层
回复 10# zhuqingedu
楼主 呀!我的意思是叫你修改本帖子的标题呀!
 楼主| 发表于 2010-9-28 20:49:31 | 显示全部楼层
噢,这样啊,我还跑去修改天空的帖子了,哈哈。
发表于 2010-11-2 16:19:20 | 显示全部楼层
逛逛,看看大家的新作
发表于 2011-1-20 09:37:03 | 显示全部楼层
发表于 2012-7-22 23:24:29 | 显示全部楼层
最近也在研究系统服务,嘿嘿。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-18 22:28 , Processed in 0.091369 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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