Jump to content
Sign in to follow this  
datas2k

how to count services number ?

Recommended Posts

datas2k

Hi!

My quaestion is how im count the number of existing services ?

$objWMIService      = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$Services           = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", BitOR(0x10,0x20))

ConsoleWrite ("----------------------" & @LF & UBound($Services) & @LF & "----------------------" & @LF)
Im ask that cus after getting the services list, counting with UBound not work, always get a zero value.

For example with that loop im can count:

For $objItem In $Services
    $i = $i+1
Next

.... but im think it is an ugly method.

Share this post


Link to post
Share on other sites
azure

Hi!

My quaestion is how im count the number of existing services ?

$objWMIService      = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$Services           = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", BitOR(0x10,0x20))

ConsoleWrite ("----------------------" & @LF & UBound($Services) & @LF & "----------------------" & @LF)
Im ask that cus after getting the services list, counting with UBound not work, always get a zero value.

For example with that loop im can count:

For $objItem In $Services
    $i = $i+1
Next

.... but im think it is an ugly method.

$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colProcessList = $objWMIService.ExecQuery("Select * from Win32_Service")

ConsoleWrite($colProcessList.Count & " services found.")
For $objProcess In $colProcessList
    ConsoleWrite($objProcess.Name)
Next

Share this post


Link to post
Share on other sites
datas2k

$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colProcessList = $objWMIService.ExecQuery("Select * from Win32_Service")

ConsoleWrite($colProcessList.Count & " services found.")
For $objProcess In $colProcessList
    ConsoleWrite($objProcess.Name)
Next
ah thx :)

im a newb in autoit

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×