[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to Kill iexplore

Parv G.

12/21/2007 4:59:00 PM

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!
--
Posted via http://www.ruby-....

1 Answer

Daniel Berger

12/21/2007 7:01:00 PM

0



On Dec 21, 9:59=A0am, "Parv G." <ghotr...@yahoo.com> wrote:
> 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.