Kyan Posted September 29, 2014 Posted September 29, 2014 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 Sleep(10) WEnd $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] $aServicesList[UBound($aServicesList)-1][0]=$a[$x] $aServicesList[UBound($aServicesList)-1][1]=$a[$x+1] Next $aServicesList[0][0]=UBound($aServicesList)-1 Return $aServicesList EndFunc Exemple usage (for starters) #include <Array.au3> ;You need this only for _arrayDisplay Local $aServ $aServ = _GetServicesList() _ArrayDisplay($aServ) Exit 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now