PC Review


Reply
Thread Tools Rate Thread

Check if process running then terminate if is?

 
 
Smokey Grindel
Guest
Posts: n/a
 
      10th Apr 2008
Is there anyway to check if an external process is running, then terminate
it if it is? my problem right now is in my installer the user might try to
upgrade while the program is running... I want to check if it is running,
notify them it is, then ask them if they want to terminate it or not...
thanks!


 
Reply With Quote
 
 
 
 
Lloyd Sheen
Guest
Posts: n/a
 
      10th Apr 2008

"Smokey Grindel" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Is there anyway to check if an external process is running, then terminate
> it if it is? my problem right now is in my installer the user might try to
> upgrade while the program is running... I want to check if it is running,
> notify them it is, then ask them if they want to terminate it or not...
> thanks!
>


There is a Kill method on the Process class.

There is a CloseMainWindow function on the Process class which is most
likely a better way to go, since it gives the process a chance to cleanup.
If the process is a runaway then Kill would be the "best" way to go.

Hope this helps
LLoyd SHeen

 
Reply With Quote
 
kimiraikkonen
Guest
Posts: n/a
 
      10th Apr 2008
On Apr 10, 8:27 pm, "Smokey Grindel" <nos...@nospam.com> wrote:
> Is there anyway to check if an external process is running, then terminate
> it if it is? my problem right now is in my installer the user might try to
> upgrade while the program is running... I want to check if it is running,
> notify them it is, then ask them if they want to terminate it or not...
> thanks!


Smokey,
To terminate a process:

' Be careful not to add ".exe" extension to your process name
For Each myprocess As Process In Process.GetProcessesByName("process")
myprocess.Kill()
Next
 
Reply With Quote
 
Smokey Grindel
Guest
Posts: n/a
 
      10th Apr 2008
Thanks both of you!

"kimiraikkonen" <(E-Mail Removed)> wrote in message
news:1701b591-8847-4384-ae2f-(E-Mail Removed)...
> On Apr 10, 8:27 pm, "Smokey Grindel" <nos...@nospam.com> wrote:
>> Is there anyway to check if an external process is running, then
>> terminate
>> it if it is? my problem right now is in my installer the user might try
>> to
>> upgrade while the program is running... I want to check if it is running,
>> notify them it is, then ask them if they want to terminate it or not...
>> thanks!

>
> Smokey,
> To terminate a process:
>
> ' Be careful not to add ".exe" extension to your process name
> For Each myprocess As Process In Process.GetProcessesByName("process")
> myprocess.Kill()
> Next


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminate a child process when parent process is killed =?Utf-8?B?YmFyYnV0eg==?= Microsoft Dot NET Framework 3 9th Jul 2007 10:29 PM
Long running requests terminate -- should I start a process on the server instead? mortb Microsoft ASP .NET 2 9th Jan 2006 03:23 PM
How to Check if a Process is Running =?Utf-8?B?Q2hhcGxhaW4gRG91Zw==?= Microsoft Excel Programming 0 24th May 2005 05:29 PM
Batch command to terminate a running process? NoSpam@aol.com Windows XP General 7 7th May 2005 06:43 PM
System.Diagnostics.Process, any way to terminate the specified process AND any child processes which were started by it? =?Utf-8?B?RnJhbmsgSm9uZXM=?= Microsoft Dot NET Framework 3 19th Oct 2004 02:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:31 AM.