Jump to content
Sign in to follow this  

Get window's services list and current state (function)

Recommended Posts

Guess this will be my first countribute for examples scripts

This may come handy for some people one day
Func _GetServicesList() ;[0][0] Services Count, [x][0] Service name, [x][1] Service State
    Local $iExitCode, $st,$a,$aServicesList[1][2],$x
    $iExitCode = Run(@ComSpec & ' /C sc queryex type= service state= all', '', @SW_HIDE, 0x2)
    While 1
        $st &= StdoutRead($iExitCode)
        If @error Then ExitLoop
    $a = StringRegExp($st,'(?m)(?i)(?s)(?:SERVICE_NAME|NOME_SERVI€O)\s*?:\s+?(\w+).+?(?:STATE|ESTADO)\s+?:\s+?\d+?\s+?(\w+)',3)
    For $x = 0 To UBound($a)-1 Step 2
        ReDim $aServicesList[UBound($aServicesList)+1][2]
    Return $aServicesList

Exemple usage (for starters)

#include <Array.au3> ;You need this only for _arrayDisplay
Local $aServ
$aServ = _GetServicesList()

I only seek for the service state since is the only thing I needed, adding other stuff only will take more time for the function run, but I can give a hand on that if you need it.

PS: Works 100% on EN/PT language, other languages need stdout text further evaluation...

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better

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  

  • Create New...