I Just want to manage Windows Services through Scripting languages( VB Script开发者_如何学运维 or Something ). Like Starting, stopping, Getting the status, Checking the dependencies etc. Please help with Code snippets or URL referances.
Use this script to start a service:
'' Starts service 'strService' on computer named 'strComputer'
''
Sub StartService(strService, strComputer)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strService & "'")
For Each objService in colListOfServices
objService.StartService
Next
End Sub
'' Start Windows CardSpace service on local host:
StartService "idsvc", "."
Instead of StartService
, you can use StopService
to stop the service. See this MSDN article for other useful methods of Win32_Service
.
精彩评论