Compartir a través de


How to: Script Win32 Provider Methods

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following sample scripts show how to use the Win32_Service class to start and stop Speech Server.

For more information, see Win32_Service class.

Example

The following sample shows how to start Speech Server.

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name='MSSpeechService'")

For Each objService in colServiceList
    errReturn = objService.StartService()
Next

WScript.Sleep 20000

Set colServiceList = objWMIService.ExecQuery("Associators of " _
   & "{Win32_Service.Name='MSSpeechService'} Where " _
        & "AssocClass=Win32_DependentService " & "Role=Dependent" )

For Each objService in colServiceList
    objService.StartService()
Next

The following sample shows how to stop Speech Server.

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Associators of " _
   & "{Win32_Service.Name='MSSpeechService'} Where " _
        & "AssocClass=Win32_DependentService " & "Role=Antecedent" )

For Each objService in colServiceList
    objService.StopService()
Next

WScript.Sleep 20000

Set colServiceList = objWMIService.ExecQuery _
        ("Select * from Win32_Service where Name='MSSpeechService'")

For Each objService in colServiceList
    errReturn = objService.StopService()
Next

See Also

Tasks

How to: Use WMI Object Methods

Other Resources

Speech Server Administration Through WMI