How to Kill iexplore

P

Parv G.

Hi,

Can anybody give a code example on how to kill a process using the
"image name" (in windows task manager)?

is there something like Process.kill_image(image_name)?

Thanks!
 
D

Daniel Berger

Hi,

Can anybody give a code example on how to kill a process using the
"image name" (in windows task manager)?

is there something like Process.kill_image(image_name)?

No, because that would kill all processes with that name. You can do
this:

require 'sys/proctable'
require 'win32/process'
include Sys

ProcTable.ps do |process|
Process.kill(1, process.pid) if process.caption =3D=3D image_name
end

I recommend require'ing win32/process so you get the better
Process.kill version.

Regards,

Dan

PS - I just discovered that you'll need to add "require 'time'" to the
top of the proctable.rb (windows.rb) file. It's fixed in CVS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top