find process by processname

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
J

Jeremy Chapman

I wanted to find a process by the ProcessName property, but I discovered
that if the executable name changes, the ProcessName reflects that. Is
there some way for me to identify a process by something that may not
change?
 
Hello,

When does the executable name change?

Does it change while the process is running? (I don't believe this is
possible)
Or are you saying your application looks for a process named "X", however,
the application keeps getting renamed "X", "Y", "Z" so you cannot hardcode
in your application the name of the process to lookup?

I'm not aware of another way to determine a process (that's not saying there
isn't another way though).

Maybe we can solve your problem a different way. Could you give more
information on what the situation is and what you are trying to accomplish.

Do you control the name of this other process? How often does this other
process change it's name?
If you control the other process name and/or if does not change frequently
you may be able to use a config file, however, then you are still having to
update that config file on each client everytime the you expect the process
name to change. If the clients are always connected you could have a
central config file on a server that you update.

Let us know more about the problem,

--
Tom Krueger

Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.
 
The processname will change if someone changes the file name of the
executable.

Essentially there are two executables a.exe and b.exe. b.exe will run many
instances. i need a button in a.exe which shuts down any b.exe processes.
Orignally I just cycled through all the processes and closed them if they
were named b.exe but because the file can be renamed, this is not a failsafe
method. as well, searching by the main window title isn't good either
because that can change dynamically depending on what b.exe is doing at the
time.

I know that the filename shouldn't really change, but it can and has, so
that can be a problem.

I was hoping that I could write some code in application b that would set
it's processname to a specific value, but I'm not sure this is possible.
 
I wish you would have answered all my questions so I could help with a
solution. First, I want to start by saying there may be a way to identify
processes other than names, however, I don't know of them. Depending on
your situation you should be able to find an alternate solution.

1) It sounds like the file name does not change very often. So you could
just have a config file that contains a list of process names. If your
application is always connected to the network you could put the file on a
network share or web for ease of maintenance or use a sophisticated
application updater model.

2) If you control the application which the name keeps changing, you could
code in that application to add and remove a registry or per user config
file entry on startup and termination. The the application that looks for
the processes could just check those entries for the process names. You
might even be able to store process ids and then not have to iterate through
all the running processes.

Hope that helps,

Tom Krueger

Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top