Schlawiner 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 comment Share on other sites More sharing options...
Danp2 Posted December 1, 2021 Share Posted December 1, 2021 https://www.autoitscript.com/autoit3/docs/functions/ProcessExists.htm Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Schlawiner 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 comment Share on other sites More sharing options...
Schlawiner 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 comment Share on other sites More sharing options...
Nine 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") “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (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 Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Developers Jos 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 comment Share on other sites More sharing options...
Earthshine 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 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