'==========================================================================
'
' NAME: StopStartSpooler.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 10/18/2004
'
' COMMENT: <comment>
'
'==========================================================================
On Error Resume Next
'start with getting the local computer name
strComputer = "."
'now stop the services
Set objWMI = getobject("winmgmts://" & strComputer)
StopService ("Spooler")
WScript.Sleep 3000
StartService ("Spooler")
'sub to stop the services
Sub StopService (ServiceName)
queryString = "select state from win32_service " _
& "where displayname='"& ServiceName & "'"
set results = objWMI.execquery(queryString)
for each service in results
if service.state = "Running" then
service.stopService
end if
next
End Sub
'sub to start the services
Sub StartService (ServiceName)
queryString = "select state from win32_service " _
& "where displayname='"& ServiceName & "'"
set results = objWMI.execquery(queryString)
for each service in results
if service.state <> "Running" then
service.startService
end if
next
End Sub