Advertisement
Advertisement
| 06.19.2008 at 12:30PM PDT, ID: 23500217 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: |
' Note: Each Service is case sensitive.
arrServices = Array("Telephony","Windows Audio")
' Server to stop services on
strServer = "servername"
If Ping(strServer) = True Then
For Each strService In arrServices
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strServer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where DisplayName='"& strService & "'")
On Error Resume Next
For Each objService In colListOfServices
If Err.Number = 0 Then
On Error GoTo 0
If objService.State = "Running" Then
objService.StopService()
Wscript.Sleep 5000
End If
objService.ChangeStartMode "Disabled"
Else
Err.Clear
On Error GoTo 0
WScript.Echo strService & " service was not found on " & strServer
End If
Next
Next
Else
WScript.Echo strServer & " could not be pinged."
End If
''WScript.Echo "Script finished."
Function Ping(strComputer)
Dim objShell, boolCode
Set objShell = CreateObject("WScript.Shell")
boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
If boolCode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
|