Schlawiner 0 Posted December 1, 2021 Share Posted December 1, 2021 Hi With the following line I read out a process ID based on the path. $s_Path = StringReplace($serverdir & $absolutedir & $g_c_sServerEXE, "\", "\\") $g_sPID = ObjGet("winmgmts:").ExecQuery('SELECT ProcessID FROM Win32_Process WHERE ExecutablePath="' & $s_Path & '"', "WQL", 16).ItemIndex(0).ProcessID If the process does not exist, I get an error message. Which means I have to check beforehand whether the process exists. Does somebody has any idea. Link to post Share on other sites
Danp2 1,227 Posted December 1, 2021 Share Posted December 1, 2021 https://www.autoitscript.com/autoit3/docs/functions/ProcessExists.htm WebDriver UDF [GH&S] Latest version Wiki FAQs Link to post Share on other sites
Schlawiner 0 Posted December 1, 2021 Author Share Posted December 1, 2021 that would be too easy, you can just call up the application. However, there are situations where the same applications run under different paths. If you only want to stop one of them, you need the query using the path via winmgmts. Link to post Share on other sites
Schlawiner 0 Posted December 1, 2021 Author Share Posted December 1, 2021 $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE ExecutablePath="' & $s_Path & '"', "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then ...... EndIf right ? Link to post Share on other sites
Nine 1,501 Posted December 1, 2021 Share Posted December 1, 2021 You can also check for the object count. In some situations, it will create an object with 0 occurrence : If Not $colItems.count Then Exit MsgBox(0, "", "Not found") Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in au3 files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Developers Jos 2,608 Posted December 1, 2021 Developers Share Posted December 1, 2021 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
Earthshine 767 Posted December 1, 2021 Share Posted December 1, 2021 (edited) you can even read the execution path. i have done this when writing a simple process finder read the help Function _WinAPI_GetProcessFileName (autoitscript.com) Retrieves the fully-qualified path of the executable file for the specified process Edited December 1, 2021 by Earthshine My resources are limited. You must ask the right questions Link to post Share on other sites
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