Friday, December 18, 2009

Start Service with a script

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
' Obtain an instance of the the class
' using a key property value.
Set objShare = objWMIService.Get("Win32_Service.Name='ActiveMQ'")

' no InParameters to define

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='ActiveMQ'", "StartService")

' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue

No comments: