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!
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!
On Dec 21, 9:59 am, “Parv G.” [email protected] 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 == 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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs