Tuesday, May 20, 2014

VB Script to Stop a service

strComputer = "."
strServiceName = "msiserver"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
    objService.StopService()
Next

No comments:

Post a Comment