Wednesday, October 20, 2010

Changing a Service Account Password

Changes the service account password for any services running under the hypothetical service account Netsvc.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service")
For Each objservice in colServiceList
    If objService.Startname = ".\netsvc" Then
        errReturn = objService.Change( , , , , , , , "password") 
    End If
Next

No comments:

Post a Comment

 

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