VAN0 Posted June 28, 2019 Share Posted June 28, 2019 (edited) Hello. How can I check if a process with specific command line (full exec path + parameters) already running? i.e. "C:\Windows\sytem32\NOTEPAD.EXE" C:\test.txt Found this topic, but it only checks for full path of executable, not parameters. Thank you. Edited June 28, 2019 by VAN0 Link to comment Share on other sites More sharing options...
Exit Posted June 28, 2019 Share Posted June 28, 2019 (edited) $exist = 0 $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $oProcesses = $oWMI.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30) For $oProcess In $oProcesses If ($oProcess.Name = "Notepad.exe" And StringInStr($oProcess.CommandLine, "C:\test.txt")) Then $exist = 1 Next MsgBox(64+262144, Default, "Process " & ($exist?"already":"not") & " running.",0) Edited June 28, 2019 by Exit mLipok and VAN0 1 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
rudi Posted June 28, 2019 Share Posted June 28, 2019 @Exit Thats Magic For $test = -2 To 5 ConsoleWrite("$test=" & $test & " --> " & ($test?"true":"false") & @CRLF) Next $test=-2 --> true $test=-1 --> true $test=0 --> false $test=1 --> true $test=2 --> true $test=3 --> true $test=4 --> true $test=5 --> true +>13:25:21 AutoIt3.exe ended.rc:0 +>13:25:21 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6568 Even knowing this by your post I cannot find anything in the help file System covering this way to "Switch" between two optional strings using a variables value state TRUE | FALSE Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
BrewManNH Posted June 28, 2019 Share Posted June 28, 2019 Look in the help file for Ternary operator for help with the "?:" conditional testing. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rudi Posted June 28, 2019 Share Posted June 28, 2019 Very nice option to do if/then/else operations in just one tiny line! Now it noticed, that it's mentioned "related --> Ternary" in the help file System for if/then/else Tx! Earth is flat, pigs can fly, and Nuclear Power is SAFE! 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