cypher175 Posted March 20, 2010 Posted March 20, 2010 How could I get the Locations + PID of multiple running processes with the same name..?? If 5 processes are running that all have the same name, but each are located in different locations.. How can I get the location + PID for each of those processes..??
Yashied Posted March 20, 2010 Posted March 20, 2010 (edited) #Include <WinAPIEx.au3> $List = ProcessList('notepad.exe') If Not @error Then For $i = 1 To $List[0][0] ConsoleWrite($List[$i][0] & ' ' & $List[$i][1] & ' ' & _WinAPI_GetModuleFileNameEx($List[$i][1]) & @CR) Next EndIfWinAPIEx.au3 Edited March 20, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
cypher175 Posted April 3, 2010 Author Posted April 3, 2010 thanks for the code example.. What if there are multiple instances of the same AutoItExe Process running simultaneously and I need to get the PID of the 1st executed AutoItExe so i can close all the other instances and only have the 1st executed AutoItExe continue to run..??
TMXOD Posted April 3, 2010 Posted April 3, 2010 For this scenario, you may also wish to use the _Singleton() function of the Misc.au3 UDF.For more advanced scenarios, you could also try WMI:Local $objWMI = ObjGet("winmgmts:\\localhost\root\CIMV2") Local $objItems = $objWMI.ExecQuery('SELECT ProcessId,ExecutablePath,CreationDate FROM Win32_Process WHERE ExecutablePath LIKE "%process_name%"', "WQL", 0x10 + 0x20) If IsObj($objItems) Then For $objItem In $objItems ConsoleWriteError("PID:" & $objItem.ProcessId & " NAME:'" & $objItem.ExecutablePath & "' DATE:" & $objItem.CreationDate & @CRLF) ;;handling code goes here Next EndIfSee This MSDN Article for the functional meaning of each property.You could add each process onto a 2-dimensional array and sort by the CreationDate to get the earliest process and kill the others.
Ascend4nt Posted April 3, 2010 Posted April 3, 2010 cypher175, ProcessList will give you a list in the order the processes started. So at row[1] will be the first created process and row[last] will be the last created process. However, the current running process used to execute ProcessList() may or may not show up depending on the timing.. which is why you'd want to compare it against the current running process ID (@AutoItPID). My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
cypher175 Posted April 4, 2010 Author Posted April 4, 2010 Is there any way to get the Parent PID of the @AutoItPID..??
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