Hello!
Could you please show me how to retrieve an application's path if the process exists?
For example, if I have an application called Core Temp.exe running, how can I get to find out its path (C:\Program Files\Core Temp\Core Temp.exe) using MacroScheduler scripting?
Thank you!
How to retrieve process path?
Moderators: JRL, Dorian (MJT support)
Here is a simple example that should get you going on the right track.
You will need to tweak it for your exact needs.
You will need to tweak it for your exact needs.
Code: Select all
//get process commandline
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run>WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid
ReadFile>c:\processlist.txt,processlist
MessageModal>processlist
Excellet!. Thank you. I'm using this
and I get a text file containing only the paths of the currently running applications (like: C:\Program Files\zabkat\xplorer2\xplorer2_64.exe ).
Knowing the name of the executable (xplorer2_64.exe), how can I extract the path from the text file to a variable? or is there a way to generate a text file with information about a single process so I can read the line (that always keeps the same position) containing the path?
Code: Select all
Run>WMIC /OUTPUT:H:\TEMP\ProcessList.txt PROCESS get ExecutablePath
Knowing the name of the executable (xplorer2_64.exe), how can I extract the path from the text file to a variable? or is there a way to generate a text file with information about a single process so I can read the line (that always keeps the same position) containing the path?
something like this should work for you.
Code: Select all
//Change this variable to what you are looking for
Let>TargetProcess=wscntfy.exe
Let>k=1
Label>start
ReadLn>H:\TEMP\processlist.txt,k,line
If>line=##EOF##,finish
Position>TargetProcess,line,1,StartPos
If>StartPos>0
ExtractFilePath>line,path
MessageModal>filepath to %TargetProcess% is %path%
Goto>finish
Endif
Let>k=k+1
Goto>start
Label>finish