Looping through processes

Hi guys,
I use windows server clients.
I would like to query particular process name, and take it’s path/file location.
I can do it for single process.
the issue occurs when there is more than 1 running process, each process can run in different path (though it sounds strange, but it’s true :slight_smile: ).
how can I loop through all these particular processes with same name and copy to their path my txt file?

for example:

  1. process name: msg_server.exe
  2. runs 2 processes
  3. 1st process path: c:\temp1\
  4. 2nd process path: c:\temp2\
  • the path can by dynamically different of course.

Regards

So, we can use relevance substitution here to identify the paths, and write them out to a file with something like:

delete __appendfile
appendfile {concatenation "%0d%0a" of (pathnames of image files of processes whose (name of it as lowercase = "msg_server.exe" as lowercase))}

The concatenation "%0d%0a portion of the relevance adds the new lines between answers.

so you say that there is no way to do it in real-time and only with writing to file?

Perhaps I misunderstood…are you looking to append or prepend some text to the processes’ file path?

So, for the example you specify above with ‘msg_server.exe’ and the two paths, how would you like the output to appear?

I want to copy some file to the process file location…text file was an example.
I want to copy EXE/PS1 file, doesn’t matter.

to get process file path, I use the following query:

(pathname of image file of it) of processes whose (name of it as lowercase contains "msg_server.exe")

the issue is with that this relevance I cannot work with more than 1 process with same name…as I need to loop/iterate through the list of processes and copy the file to each location.

and that is what I want to know how to accomplish.
was it clear now?

To copy a file to the process paths, you’ll need an action, right?

In this case, I’d suggest something similar then to what I have above as a means to dynamically generate a script (such as batch) to perform the copy.

Is it the same file that you’ll be copying to each location, or different files?

Here’s some sample relevance assuming the same file being copied to the various locations:

("copy C:\temp\foo.txt " & preceding text of last "\" of it & "\foo.txt") of unique values of pathnames of image files of processes whose (name of it as lowercase contains "msg_server.exe" as lowercase)
1 Like

yes thank you.
finally I’ve used powershell to loop through the file that contains the paths and copy there other file

1 Like