管理和优化服务的vbs
2007-09-04 09:52
267 查看
Dim SS, S
Dim szMsg, szTtl
Dim l
Set SS = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("Select * From Win32_Service")
szMsg = "执行了下列操作:" & vbCrLf
szTtl = "管理服务程序"
l = Len(szMsg)
For Each S In SS
Select Case UCase(Trim(S.Name))
Case "DFS":
Call StopManual()
Case "ERSVC":
Call StopManual()
Case "HELPSVC":
Call StopManual()
Case "MDM":
Call StopManual()
Case "MESSENGER":
Call StopDisable()
Case "SPOOLER":
Call PrintSpooler()
Case "REMOTEREGISTRY":
Call StopDisable()
Case "SCHEDULE":
Call StopManual()
Case "THEMES":
Call Themes()
Case "AUDIOSRV":
Call WindowsAudio()
Case "W32TIME":
Call StopManual()
End Select
Next
Set SS = Nothing
Set S = Nothing
If Len(szMsg) = l Then szMsg = "您的服务设置和本程序预期的一样!"
MsgBox szMsg, 4160, szTtl
'Distributed File System
'Error Reporting Service
'Help and Support
'Machine Debug Manager
'Task Scheduler
'Windows Time
Sub StopManual()
Dim bFlg
bFlg = False
If StrComp(S.StartMode, "Manual", 1) Then
S.ChangeStartMode("Manual")
bFlg = True
End If
If StrComp(S.State, "Stopped", 1) Then
S.StopService
bFlg = True
End If
If bFlg Then szMsg = szMsg & vbCrLf & "停止" & S.Caption & "服务,并将其启动类型设为手动。"
End Sub
'Messenger
'Remote Registry
Sub StopDisable()
Dim bFlg
bFlg = False
If StrComp(S.StartMode, "Disabled", 1) Then
S.ChangeStartMode("Disabled")
bFlg = True
End If
If StrComp(S.State, "Stopped", 1) Then
S.StopService
bFlg = True
End If
If bFlg Then szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End Sub
'Print Spooler
Sub PrintSpooler()
If StrComp(S.State, "Stopped", 1) or StrComp(S.StartMode, "Manual", 1) Then
If MsgBox("您是否有打印机?", 4132, szTtl) = 7 Then
S.ChangeStartMode("Manual")
S.StopService
szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End If
End If
End Sub
'Themes
Sub Themes()
If StrComp(S.State, "Stopped", 1) or StrComp(S.StartMode, "Manual", 1) Then
If MsgBox("您是否要使用 XP 主题风格?", 4132, szTtl) = 7 Then
S.ChangeStartMode("Manual")
S.StopService
szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End If
End If
End Sub
'Windows Audio
Sub WindowsAudio()
If StrComp(S.State, "Running", 1) or StrComp(S.StartMode, "Auto", 1) Then
S.ChangeStartMode("Automatic")
S.StartService
szMsg = szMsg & vbCrLf & "自动启用了" & S.Name & "服务。"
End If
End Sub
Dim szMsg, szTtl
Dim l
Set SS = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("Select * From Win32_Service")
szMsg = "执行了下列操作:" & vbCrLf
szTtl = "管理服务程序"
l = Len(szMsg)
For Each S In SS
Select Case UCase(Trim(S.Name))
Case "DFS":
Call StopManual()
Case "ERSVC":
Call StopManual()
Case "HELPSVC":
Call StopManual()
Case "MDM":
Call StopManual()
Case "MESSENGER":
Call StopDisable()
Case "SPOOLER":
Call PrintSpooler()
Case "REMOTEREGISTRY":
Call StopDisable()
Case "SCHEDULE":
Call StopManual()
Case "THEMES":
Call Themes()
Case "AUDIOSRV":
Call WindowsAudio()
Case "W32TIME":
Call StopManual()
End Select
Next
Set SS = Nothing
Set S = Nothing
If Len(szMsg) = l Then szMsg = "您的服务设置和本程序预期的一样!"
MsgBox szMsg, 4160, szTtl
'Distributed File System
'Error Reporting Service
'Help and Support
'Machine Debug Manager
'Task Scheduler
'Windows Time
Sub StopManual()
Dim bFlg
bFlg = False
If StrComp(S.StartMode, "Manual", 1) Then
S.ChangeStartMode("Manual")
bFlg = True
End If
If StrComp(S.State, "Stopped", 1) Then
S.StopService
bFlg = True
End If
If bFlg Then szMsg = szMsg & vbCrLf & "停止" & S.Caption & "服务,并将其启动类型设为手动。"
End Sub
'Messenger
'Remote Registry
Sub StopDisable()
Dim bFlg
bFlg = False
If StrComp(S.StartMode, "Disabled", 1) Then
S.ChangeStartMode("Disabled")
bFlg = True
End If
If StrComp(S.State, "Stopped", 1) Then
S.StopService
bFlg = True
End If
If bFlg Then szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End Sub
'Print Spooler
Sub PrintSpooler()
If StrComp(S.State, "Stopped", 1) or StrComp(S.StartMode, "Manual", 1) Then
If MsgBox("您是否有打印机?", 4132, szTtl) = 7 Then
S.ChangeStartMode("Manual")
S.StopService
szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End If
End If
End Sub
'Themes
Sub Themes()
If StrComp(S.State, "Stopped", 1) or StrComp(S.StartMode, "Manual", 1) Then
If MsgBox("您是否要使用 XP 主题风格?", 4132, szTtl) = 7 Then
S.ChangeStartMode("Manual")
S.StopService
szMsg = szMsg & vbCrLf & "停止并禁用了" & S.Caption & "服务。"
End If
End If
End Sub
'Windows Audio
Sub WindowsAudio()
If StrComp(S.State, "Running", 1) or StrComp(S.StartMode, "Auto", 1) Then
S.ChangeStartMode("Automatic")
S.StartService
szMsg = szMsg & vbCrLf & "自动启用了" & S.Name & "服务。"
End If
End Sub
相关文章推荐
- [svc][op]Ubuntu优化-服务管理(启动级别)
- Nginx服务优化(隐藏版本信息,设置管理用户和组,设置网页缓存时间)
- 部署安装PHP-5.3.28.tar.gz版本基本配置管理详解以及安装ZendGuardLoader模块优化PHP服务
- EasyDarwin云平台之EasyCMS中心管理服务消息处理优化
- Telnet服务状态之管理安全性质及优化(子旭菜鸟之编批处理)
- CentOS6优化——开机自启动服务管理
- 告诉你一个搜索服务优化方案:基于RDF的知识图谱管理
- 优化linux服务器centos7之服务管理篇
- 系统服务备份优化(VBS)
- 系统服务备份优化(VBS)
- 管理服务项目人员优化方法
- IBM:服务共享平台 全面优化管理支撑系统
- 我的Win7优化纪实1 ---服务管理
- Windows系统服务终结者 V3.3┊非常优秀服务优化管理工具┊简体中文绿色免费版
- VBS实现的系统服务备份优化代码
- 命令行管理系统服务工具 sc.exe
- 安装和配置详解 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
- Ubuntu下管理启动服务
- Unity3D对于内存的管理与优化
- 企业邮箱服务优化软件