Wednesday, October 20, 2010

Stopping Services Running Under a Specific Account

Stops all services running under the hypothetical service account Netsvc.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
    ("Select * from win32_Service")
For each objService in colServices
    If objService.StartName = ".\netsvc" Then
        errReturnCode = objService.StopService()
    End If
Next

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish