ew... I personally don't like that.
I did though came up with this piece of code. Answer to my own question...
public static void KillProcess(string ExecutablePath)
{
string strTargetProcessName =
System.IO.Path.GetFileNameWithoutExtension(Executa blePath);
Process[] Processes = Process.GetProcessesByName(strTargetProcessName);
foreach(Process p in Processes)
{
foreach(ProcessModule m in p.Modules)
{
if(ExecutablePath.ToLower() == m.FileName.ToLower())
{
p.Kill();
return;
}
}
}
}
"Derek Griffiths" <met.n.ospam@gmail> wrote in message
news:op**************@derek.workgroup...
I'd use the registry or a textfile. Have each process create a key with
its' path and use the process ID for the value (after it's started). When
you kill the process delete the key. If you want to use a textfile, then
put it in %tmp% and have it track the path of all executables and process
ids. The textfile is probably the more difficult route.
On Thu, 2 Sep 2004 16:21:05 -0700, Hayato Iriumi <hi*****@hotmail.com>
wrote:
Hello,
I have a need to kill a process. It sounds each enough, but the problem
is
that I have multiple executables running from different paths. Say, I
have
MyService.exe running from C:\FolderA and the same MyService.exe running
in
C:\FolderB. I want to kill the process that is running under C:\FolderA.
So
I guess I have a need to get the Process ID for the executable under
C:\FolderA.
How can I kill the process when you know the path to the executable?
TIA