I'm running a program in command mode (behind the scene) and output its data to form window. When the I read specific line (i.e., "run failed") I try to close the program using this code:
if (line.Contains("run failed"))
Process[] runProc = Process.GetProcessesByName("abc");
if (runProc .Length == 1)
runProc [0].Kill();
In some computers it works fine, in others I receive: "Access Denied". I understand it's concerned with the user privileges.
My question is how can I kill the process differently?
The process runs in tcl mode (don't know if it matters) and I see the last line in the form window output is:
abc%
(where abc is the program). Obviously, it shows the command prompt of the program. If it was running in a command window, I would have typing in the command window:
'quit'
and the program would have ended and terminated.
How can I send a 'quit' to tcl if something went wrong?