On Feb 6, 5:00 am, Chris <C...@discussions.microsoft.comwrote:
C# says it does not have a definition for kill. I recall using this in VB.
Are yousure this is good for C#?
"Jay Riggs" wrote:
On Feb 5, 2:04 pm, Chris <C...@discussions.microsoft.comwrote:
I know I can use this code to start a process. Any aimilar way to end one?
System.Diagnostics.Process.Start("EcpKpScript_01.e xe");
Get the process instance to want to end and call:
System.Diagnostics.Process.Kill()- Hide quoted text -
- Show quoted text -
Chris, try the following --
using System.Diagnostics;
int _processID;
private void button1_Click(object sender, System.EventArgs e) {
Process p = Process.Start("EcpKpScript_01.exe");
_processID = p.Id;
}
private void button2_Click(object sender, System.EventArgs e) {
foreach (Process proc in Process.GetProcesses()) {
if (proc.Id == _processID) {
proc.Kill();
}
}
}
Click button1 to start your program and then Click button2 to kill
it. This works for a test program I tried. Test it for yours.
-Jay