A
Anukul Singhal
Hi,
I tried the following code snippet to kill a Win32 process:
def killQTP
wmi = WIN32OLE.connect("winmgmts://")
processes = wmi.ExecQuery("select * from Win32_process")
for process in processes do
if process.Name.include? "QTPro.exe" then
puts "Name: #{process.Name}"
puts "Process ID: #{process.Pid}"
puts process.Terminate
elsif process.Name.include? "star.exe" then
puts "Name: #{process.Name}"
puts "Process ID: #{process.Pid}"
puts process.Terminate
end
end
puts "done killing QTP"
end
But the process is not getting killed when I execute the above and
simply gives "exit code: 0"
Can anyone help in case I am missing anything to execute the above code
or is there any other way of killing a Win32 process?
Thanks,
Anukul
I tried the following code snippet to kill a Win32 process:
def killQTP
wmi = WIN32OLE.connect("winmgmts://")
processes = wmi.ExecQuery("select * from Win32_process")
for process in processes do
if process.Name.include? "QTPro.exe" then
puts "Name: #{process.Name}"
puts "Process ID: #{process.Pid}"
puts process.Terminate
elsif process.Name.include? "star.exe" then
puts "Name: #{process.Name}"
puts "Process ID: #{process.Pid}"
puts process.Terminate
end
end
puts "done killing QTP"
end
But the process is not getting killed when I execute the above and
simply gives "exit code: 0"
Can anyone help in case I am missing anything to execute the above code
or is there any other way of killing a Win32 process?
Thanks,
Anukul