' list-of-Services.vbs
' Sample script to List services s-Z
' Author Guy Thomas
' -------------------------------------------------------'

Option Explicit
Dim objWMIService, objItem, objService, strServiceList
Dim colListOfServices, strComputer, strService

'On Error Resume Next
' ---------------------------------------------------------
' Pure WMI commands

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service ")

' WMI and VBScript loop

For Each objService in colListOfServices
If UCase(Left(objService.name,1)) >"S" then
strServiceList = strServiceList & vbCr & _
objService.name
End if
Next
WScript.Echo strServiceList
' End of Example WMI script to list services
