473,241 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

End an outside process

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");

Feb 5 '07 #1
4 10500
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()
Feb 5 '07 #2
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()
Feb 6 '07 #3
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

Feb 6 '07 #4
Jay, thank you!! Worked great! Here is what I did after seeing your code:

int processID;
bool processRunning = false;

private void buttonRun_Click(object sender, EventArgs e)
{
// Here is where I call engineerings ECP Script program to run
// the script we created
//System.Diagnostics.Process.Start("EcpKpScript_01.e xe");
if (processRunning == false)
{
Process p = Process.Start("EcpKpScript_01.exe");
processID = p.Id;
processRunning = true;
// update status bar
toolStripStatusLabel2.Text = "ECP Script Started";
}
else
{
foreach (Process proc in Process.GetProcesses())
{
if (proc.Id == processID)
{
proc.Kill();
}
}
processRunning = false;
// update status bar
toolStripStatusLabel2.Text = "ECP Script Stopped";
}
}

"Jay Riggs" wrote:
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

Mar 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cooldv | last post by:
After talking (emailing) to my webhoster, i have placed my access DB in a folder outside the root directory folder; and they gave me a *path.asp* file to put in my root directory folder. ** This...
0
by: wtfhits | last post by:
I'm writing my own task manager as I often change process priorities but have gotten myself into trouble on several occasions. I have discovered by keeping csrss.exe and explorer at the equal highest...
6
by: dstewart | last post by:
I have 2 Suse 9.1 boxes with similar configurations. I'm in the process of moving some PHP code from one server (192.168.0.100) to another (192.168.0.102). MySQL is running on each server, and...
20
by: Mandy Memphis | last post by:
If I perform a mousedown within a document, move the mouse outside the browser window, and then release the mouse button, the document.onmouseup event does not fire. Is there any way to detect a...
2
by: EP | last post by:
I'm using HttpRuntime.Process to process asp.net and web service requests. My question is, is it possible to dynamically provide that "file contents" of the asmx to the runtime? I'd like to...
1
by: Hayato Iriumi | last post by:
I'm wondering and doing some research on how I could change a value in ASP ..NET Cache outside aspnet worker process. Sounds problematic and I should other routes, but I'm curious as to how a...
0
by: tomko | last post by:
Hi, When I start a console program using the Process calss inside the Visual Studio IDE (debug) all the output is redirected to my stream reader. But when I run the same program from outside the...
2
by: tomko | last post by:
Hi, My program uses the Process class to start a bat file that starts an exe. When I run my program inside Visual Studio (debug) the bat and exe run in the background (are not visible) and all...
1
by: Wang E | last post by:
I've been working on an online judge(for ACM/ICPC) using C#.Programmes submitted by users can now be compiled,and it's the problem to judge.I use the Process class in C#,and my thread is as...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.