473,385 Members | 1,620 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,385 software developers and data experts.

How can I kill a process by using C#.NET Application?

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 22 '05 #1
5 9558
Take a look at the process class
http://www.knowdotnet.com/articles/processes.html
"Thomas Chan" <yw****@hkem.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 22 '05 #2
I think the process namepsace lets you access only those
processes that you application has started.

If you need to access all the active processes in your
system, then you will have to use WMI through C# code. You
can talk to WMI using System.Management namespace.

WMI gives you api to list processes, abort, kill, etc.

HTH,
Dolly
Nov 22 '05 #3
thanks~
i have read through the MSDN...I have tried it...but still don't know how to
do this...
can you give me some reference? (may be a link / sample codes)

many thanks

"Dolly" <mp****@blr.cognizant.com>
???????:07****************************@phx.gbl...
I think the process namepsace lets you access only those
processes that you application has started.

If you need to access all the active processes in your
system, then you will have to use WMI through C# code. You
can talk to WMI using System.Management namespace.

WMI gives you api to list processes, abort, kill, etc.

HTH,
Dolly

Nov 22 '05 #4
Not only processes your application starts, it can handle all processes in
the system. As long as you can get the process by name or id, you can kill
it by Process.Kill().

-jl

"Dolly" <mp****@blr.cognizant.com> wrote in message
news:07****************************@phx.gbl...
I think the process namepsace lets you access only those
processes that you application has started.

If you need to access all the active processes in your
system, then you will have to use WMI through C# code. You
can talk to WMI using System.Management namespace.

WMI gives you api to list processes, abort, kill, etc.

HTH,
Dolly

Nov 22 '05 #5
On Tue, 13 Jan 2004 20:59:42 -0800, Thomas Chan <yw****@hkem.com> wrote:

¤ 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

Try the following:

Public Sub EnumerateProcesses()

Dim WindowsProcess As Process
Dim ProcessToKill As String = "AcroRd32"

For Each WindowsProcess In Process.GetProcesses
Debug.WriteLine(WindowsProcess.ProcessName)
If WindowsProcess.ProcessName = ProcessToKill Then
WindowsProcess.Kill()
End If
Next

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 22 '05 #6

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

Similar topics

6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
5
by: Thomas Chan | last post by:
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...
1
by: Manfred Braun | last post by:
Hi All, I am writing a tool, which should monitor some exe-processes, which are not very solid. Th main function is to re-start them, if they hung, but this is complicated. I can detect things...
7
by: Joe | last post by:
If I'm using process.kill, I can only kill processes, which are created in the same login session. (I'm using win2000, I'm in the local admin group) Processes created by me in earlier logins or...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
4
by: jake | last post by:
Hello, I have an application that calls another application. Depending on what the user selects from application 2 I would like to kill application 1. How can I accomplish this? Thanks in...
5
by: Dino Buljubasic | last post by:
My application can allow a user to open a file for viewing by fetching file data from database, creating the file in a temp directory and starting appropriate process (i.e. Adobe or any other...
3
by: elrondrules | last post by:
Hi Am new to python and need your help!! this is my code snip. within my python script I have the following commands.. <snip> import os
4
by: yxq | last post by:
Hello, I want to kill the Explorer process, after Explorer process has been killed, it will restart automatically immediately. How to disable it restart automatically? for example, in Windows Task...
2
by: =?Utf-8?B?WVhR?= | last post by:
Hello, In the parent process(A), run update function, and start the update process(B), in B process, kill A, then download and update files, then restart A. I want to know can the B process kill...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.