freelanceprogrammers.org Forum Index » Visual Basic

kill process


View user's profile Post To page top
is_it_aa Posted: Thu Nov 17, 2005 7:52 pm


Joined: 17 Nov 2005

Posts: 1
kill process
Hello Friends,

How to kill a process/running program with error handling in case the program
is not running?

Thanks


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
paranjpeus Posted: Mon Dec 12, 2005 5:12 pm


Joined: 12 Dec 2005

Posts: 4
kill process
Hi ,

You should know exact process name / ID / main window name for this
to work ..

import the namespace first ...

imports System.Diagnostics.Process

then use following code ...

1) Method one Killing process if you know process name

For Each p In Process.GetProcesses()
if p.ProcessName = "your process name here" Then
p.kill()
End if
Next

2 ) Method two Killing process if you know process ID

For Each p In Process.GetProcesses()
if p.ID = "process id here" Then
p.kill()
End if
Next

3 ) Method three Killing process if you know process main window
title

For Each p In Process.GetProcesses()
if p.MainWindowTitle = "process main window name here" Then
p.kill()
End if
Next

Thanks,

Amol Paranjpe
--- In VBBeginners@yahoogroups.com, "moonwalk" <nike.gold@g...>
wrote:
>
> Hello Friends,
>
> How to kill a process/running program with error handling in case
the program is not running?
>
> Thanks
>
>
> [Non-text portions of this message have been removed]
>
Reply with quote
Send private message
View user's profile Post To page top
paranjpeus Posted: Mon Dec 12, 2005 5:14 pm


Joined: 12 Dec 2005

Posts: 4
kill process
Hi ,

You should know exact process name / ID / main window name for this
to work ..

import the namespace first ...

imports System.Diagnostics.Process

then use following code ...

1) Method one Killing process if you know process name

For Each p In Process.GetProcesses()
if p.ProcessName = "your process name here" Then
p.kill()
End if
Next

2 ) Method two Killing process if you know process ID

For Each p In Process.GetProcesses()
if p.ID = "process id here" Then
p.kill()
End if
Next

3 ) Method three Killing process if you know process main window
title

For Each p In Process.GetProcesses()
if p.MainWindowTitle = "process main window name here" Then
p.kill()
End if
Next

write error handling code after the for loop ..

Thanks,

Amol Paranjpe


--- In VBBeginners@yahoogroups.com, "moonwalk" <nike.gold@g...>
wrote:
>
> Hello Friends,
>
> How to kill a process/running program with error handling in case
the program is not running?
>
> Thanks
>
>
> [Non-text portions of this message have been removed]
>
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help