473,626 Members | 3,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9589
Take a look at the process class
http://www.knowdotnet.com/articles/processes.html
"Thomas Chan" <yw****@hkem.co m> wrote in message
news:Oe******** ******@tk2msftn gp13.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.Manageme nt 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.cog nizant.com>
???????:07***** *************** ********@phx.gb l...
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.Manageme nt 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.cog nizant.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.Manageme nt 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.co m> 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 EnumerateProces ses()

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

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

End Sub
Paul ~~~ pc******@amerit ech.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
7041
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 os.kill(self.popen.pid, signal.SIGTERM) Everything works fine on MacOSX. However, I'm doing a port to Solaris (so I can run it on my web site) and find that the child processes are not stopping! Solaris is creating TWO new processes: one for the SHELL...
5
5210
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 anyone kindly sugguest some idea? Thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
3145
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 like no longer generating IO or such properties and I use WMI to do that. I am also looking for attached subprocesses, which are one of the system debuggers. I wrote a test-program, which creates a divide by zero error after some seconds. I can...
7
2985
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 even processes of other accounts cannot be killed. I get exceptions, like "You have no permission...". I've tried to do the job in a console application and in a service running under my account (which is in the local admin group of win2000),...
0
2180
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 command button in the application. So the code goes something like this: psiBat = New ProcessStartInfo(arrRun.Item(0)(1)) psiBat.WindowStyle = ProcessWindowStyle.Hidden
4
1408
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 advance. Jake
5
4589
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 depending of file type) to open the file. when I close my application, it is suppose to clean all files it created in temp directory. I do this by : for each file in temp
3
6491
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
7171
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 Manager, you can kill explorer process, but it will not restart automatically. My code: ///////////////////////////////////////////// For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
2
2496
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 A process? Thank you
0
8199
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.