473,326 Members | 2,255 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,326 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 9552
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: 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.