From: Ara.T.Howard@... Date: 2005-05-24T23:20:22+09:00 Subject: Re: Killing a Process started with Kernel.system On Tue, 24 May 2005, Gavin Kistner wrote: > On May 23, 2005, at 11:40 PM, Martin aus Chemnitz wrote: >> Under Windows, I want to start an external program and kill it on >> exitting my Ruby script. >> >> begin >> $t = Thread.new { system("everlasting") } >> ... >> ensure >> $t.kill >> end >> >> does not stop the everlasting program, it stops $t, not its child >> processes. Such a command is urgently needed! > > Here's a way to kill any process using Win32OLE: > > require 'win32ole' > > class WIN32OLE > def to_a > a = []; self.each{ |p| a<
end > end > > # Find the process for the player > mgmt = WIN32OLE.connect('winmgmts:\\\\.') > process = mgmt.InstancesOf("win32_process").to_a.find{ |proc| > proc.name =~ /myapp.exe/ } > process.Terminate so no way by pid? -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================