' StopService.vbs
' Author Guy Thomas http://computerperformance.co.uk
' Version 2.7 - March 2005
' ----------------------------------------'
'
Option Explicit
Dim objService, objWMI, colListOfServices, intExSrv
Dim strExService1, strExService2, strExService3, strExService4
Dim strComp, strWMIsrv
' Amend strExService if you do not have exchange e.g. Alerter
strExService1 = "MSexchangeIS"
strExService2 = "MSexchangeMTA"
strExService3 = "MSexchangeSA"
strExService4 = "MSexchangeSRS"
intExSrv = 1
' Loops through all the Exchange services
' Uses Select Case rather than If then Elseif, end if.
For intExSrv = 1 To 4
Select Case intExSrv
Case 1 strWMIsrv = strExService1
Case 2 strWMIsrv = strExService2
Case 3 strWMIsrv = strExService3
Case 4 strWMIsrv = strExService4
End Select
WScript.Echo "strWMIsrv = " & strWMIsrv
' Section using WMI to interrogate the services
' Note "." means local computer.
' Note strWMIsrv in Line 37 (ish)
strComp = "."
Set objWMI = GetObject("winmgmts:\\" & strComp & "\root\cimv2")
Set colListOfServices = objWMI.ExecQuery("Select * from " _
& "Win32_Service Where Name ='" & strWMIsrv & "'")
' See how it cycles through colListofServices until it gets a match
' Then stops the objService
For Each objService in colListOfServices
objService.StopService()
Next
Next
WScript.Echo "Now check: Services, MS Exchange xx" & vbCr _
& "This script cuts the time it takes to reboot your Exchange server."
WScript.Quit
' End of Script
-------------------
Thanks,
http://sccm07.blogspot.com/
13 January 2009
VBSCRIPT To Shutdown Exchange 200x server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment