33 lines
1.0 KiB
Plaintext
33 lines
1.0 KiB
Plaintext
' Copyright (c) Microsoft Corporation, All Rights Reserved
|
|
'***************************************************************************
|
|
'
|
|
' WMI Sample Script - Pauses a service (VBScript)
|
|
'
|
|
' This script demonstrates how to pause a specific service from instances of
|
|
' Win32_Service.
|
|
'
|
|
' NOTE: The service must support pausing and be running already.
|
|
'
|
|
' NOTE: This script only applies to NT-based systems since Win9x does support services
|
|
'
|
|
'
|
|
'***************************************************************************
|
|
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='Schedule'")
|
|
|
|
for each Service in ServiceSet
|
|
SupportsPause = Service.AcceptPause
|
|
if SupportsPause = true then
|
|
RetVal = Service.PauseService()
|
|
if RetVal = 0 then
|
|
WScript.Echo "Service paused"
|
|
else
|
|
if RetVal = 1 then
|
|
WScript.Echo "Pause not supported"
|
|
else WScript.Echo "An error occurred:" & RetVal
|
|
End If
|
|
End If
|
|
else
|
|
WScript.Echo "Service does not support pause"
|
|
end if
|
|
next
|