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