require 'win32ole'
mgmt = WIN32OLE.connect('winmgmts:\\\\.')
mgmt.InstancesOf("win32_process").each{ |proc|
puts proc.name
}
mgmt.ExecQuery("Select * from Win32_Process Where Name = ' Notepad.exe'").each{ |item|
item.Terminate()
}
On 4/9/06, Rodrigo Julian Martin <[EMAIL PROTECTED]
> wrote:
Hi!I'm trying to make a code for killing all running processes that i need to close.I've this function for _javascript_:[code]function KillProcess(PName)
{
var Count = 0;
var p = Sys.WaitProcess(PName, 1000, 1);
while (p.Exists) {
Count++;
p.Terminate();
while (p.Exists) Delay(50);
p = Sys.WaitProcess(PName, 1000, 1);
}
return Count;
}
...
KillProcess("Excel");
...[/code]Is there a way to do this in ruby+watir? I was reading about the Sys::Process, but I don't find the way. I'm running on a Windows 2000.I really don't want to end up making a bat file =(..any help would be really appreciatedCheers from Argentina, and Thanks in advance!Rodrigo Julian Martin
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
