473,396 Members | 1,767 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,396 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 10504
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.