UritOR Posted October 26, 2015 Share Posted October 26, 2015 $pID = ProcessList () for $i=1 to $pID[0][0] step +1 MsgBox(0,"Process name", $pID[$i][0]) Next exitHello, these lines run thru all processes and shows their name.1) It shows the processes not in an alphabetical order (anyone knows how the array returned? what order?)2) After I get a process name I want to read its' description.Anyone can help me?Thanx Link to comment Share on other sites More sharing options...
MagnumXL Posted October 26, 2015 Share Posted October 26, 2015 I believe the process list is by window order but regardless you can sort it with _ArraySortGet the process description by using _WinAPI_GetFileVersionInfo and then _WinAPI_VerQueryValue Link to comment Share on other sites More sharing options...
jguinch Posted October 26, 2015 Share Posted October 26, 2015 One way (using SmOke_N's code https://www.autoitscript.com/forum/topic/166042-the-are-another-best-way-to-know-if-a-windows-service-is-running-by-your-path/?do=findComment&comment=1212606) :expandcollapse popup#include <WinAPI.au3> #include <WinAPIProc.au3> #include <Array.au3> #include <FileConstants.au3> _EnableDebugPrivilege() Local $aProcessList = ProcessList() _ArraySort($aProcessList, 0, 1) Local $n = 0 For $i = 1 To $aProcessList[0][0] $sProcessPath = _ProcessGetPathEx($aProcessList[$i][1]) If $sProcessPath <> "" Then $n += 1 $aProcessList[$n][0] = $sProcessPath $aProcessList[$n][1] = FileGetVersion ( $aProcessList[$n][0], $FV_FILEDESCRIPTION ) If $aProcessList[$n][1] = "" Then $aProcessList[$n][1] = $sProcessPath EndIf Next Redim $aProcessList[$n + 1][2] _ArrayDisplay($aProcessList) ; @param1 = process name or pid ; @param2 = default 0 = drive\etc format ; true = native system path format Func _ProcessGetPathEx($v_process, $b_native = 0) Local $i_pid = ProcessExists($v_process) If Not $i_pid Then ; process does not exist Return SetError(1, 0, "") EndIf Local $sz_filepath = "" ; are we working with anything less than vista? Local Static $nWVers = ($__WINVER <> "") ? $__WINVER : __WINVER() If $nWVers < 0x0600 Then ; _WinAPI_GetProcessFileName seems misleading $sz_filepath = _WinAPI_GetProcessFileName($i_pid) Return SetError(@error, @extended, $sz_filepath) EndIf ; vista and above, should help with possible 64bit issues as well Local $h_k32 = DllOpen("Kernel32.dll") If @error Or Not $h_k32 Then ; could not open kernel32.dll Return SetError(2, 0, 0) EndIf Local Const $pgp_PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 Local Const $pgp_PROCESS_QUERY_INFORMATION = 0x0400 Local Const $pgp_PROCESS_NAME_NATIVE = 0x00000001 ; open process with query info only Local $a_openprocess = DllCall($h_k32, "handle", "OpenProcess", _ "long", BitOR($pgp_PROCESS_QUERY_INFORMATION, _ $pgp_PROCESS_QUERY_LIMITED_INFORMATION), _ "int", 0, "long", $i_pid) Local $i_err = @error If $i_err Or Not IsArray($a_openprocess) Then DllClose($h_k32) ; error code from dllcall sent as extended Return SetError(3, $i_err, 0) EndIf Local $h_openproc = $a_openprocess[0] Local $n_native = $b_native ? $pgp_PROCESS_NAME_NATIVE : 0 Local $a_query = DllCall($h_k32, "bool", "QueryFullProcessImageNameW", _ "handle", $h_openproc, "dword", $n_native, "wstr", "", "int*", 4096) $i_err = @error If $i_err Or Not IsArray($a_query) Then DllClose($h_k32) ; error code from dllcall sent as extended Return SetError(4, $i_err, 0) EndIf _WinAPI_CloseHandle($h_openproc) DllClose($h_k32) ; return string length as extended Return SetError(0, $a_query[4], $a_query[3]) EndFunc ;==>_ProcessGetPathEx Func _EnableDebugPrivilege() Local $h_curproc = _WinAPI_GetCurrentProcess() Local $h_token = _Security__OpenProcessToken($h_curproc, _ BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) If Not $h_token Then Return SetError(2, 0, 0) EndIf Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_DEBUG_NAME) Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword") Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv) DllStructSetData($t_tokenpriv, 1, 1) DllStructSetData($t_tokenpriv, 2, $n_sdn) DllStructSetData($t_tokenpriv, 3, 0) DllStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED) Local $n_tokensize = DllStructGetSize($t_tokenpriv) Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _ $p_tokenpriv, $n_tokensize) _WinAPI_CloseHandle($h_token) Return SetError(Not $b_ret, 0, $b_ret) EndFunc ;==>_EnableDebugPrivilege Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
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