How to kill in process in task manager?

  • Thread starter Thread starter Thomas Chan
  • Start date Start date
T

Thomas Chan

I have an application that need to launch acrobat reader. But before I
open acrobat reader, I want to check there is any existing acrobat
reader opening and kill them first.

What can I do? Can anyone kindly sugguest some idea?
Thanks
 
using System.Diagnostics;

public class A
{
....
private void checkacrobat()
{
Process[] prs = Process.GetProcesses();
foreach(Process pr in prs)
{
if(pr.ProcessName == "****ProcessName")
pr.Kill();
}
}

I think this will close the process
 
Hi Thomas,
You can use the System.Diagnostic.Process Class to find
the what are all the applications running and can kill
that application.

Regards,
Amal
 
Thomas,

Consider the following implication - the user might have started Acrobat
Reader to open a document that has nothing to do with your application. With
your approach, you will silently terminate such an Acrobat Reader instance.
This will most likely be unexpected and unpleasant surprise to the user.
 
Thanks for your advice.
Actually, what i want to do is to print a pdf file....
I have found a command from the acrobat forum and run it through the process
class. However, it does not terminate the acrobat reader after printing the
pdf file....

By the way, do you have any other ideas to print a pdf file using C#?
I really need help....thanks


Dmitriy Lapshin said:
Thomas,

Consider the following implication - the user might have started Acrobat
Reader to open a document that has nothing to do with your application. With
your approach, you will silently terminate such an Acrobat Reader instance.
This will most likely be unexpected and unpleasant surprise to the user.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Thomas Chan said:
I have an application that need to launch acrobat reader. But before I
open acrobat reader, I want to check there is any existing acrobat
reader opening and kill them first.

What can I do? Can anyone kindly sugguest some idea?
Thanks
 
Back
Top