strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery ("Select * from Win32_Service where StartMode = 'Manual'")
For Each objService in colServiceList
errReturnCode = objService.Change( , , , , "Disabled")
WScript.Echo "Changed manual service to disabled: " & objService.Name
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='Alerter'")
For Each objService in colListOfServices
objService.StartService()
Wscript.Echo "Started Alerter service"
Next
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
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where AcceptStop = True")
For Each objService in colServices
Wscript.Echo objService.DisplayName
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Associators Of " _
& "{Win32_Service.Name='dhcp'} Where " _
& "AssocClass=Win32_DependentService " _
& "Role=Dependent")
For Each objService in colServiceList
Wscript.Echo objService.DisplayName
Next
PowerShell
$query = "Associators Of {Win32_Service.Name='dhcp'} Where AssocClass=Win32_DependentService Role=Dependent"
Get-WmiObject -Query $query -Namespace "root\cimv2" | format-list DisplayName