路漫漫其修远兮,吾将上下而求索

使用ruby关闭ie进程

上一篇 / 下一篇  2009-11-30 09:50:16 / 个人分类:Ruby_Watir

使用watir的close_all方法,有时会关闭不掉IE,最好的办法就是直接终止IE进程,可以写一个关闭ie的方法

 

require 'win32ole'
    # Returns the number of windows processes running with the specified name.
    def  close_ie
      mgmt = WIN32OLE.connect('winmgmts:\\\\.')
      processes=mgmt.instancesof("win32_process")
      processes.each do |process|
          puts process
         if  process.name =="iexplore.exe" then      
          process.terminate()
          end
        end
    end

这样调用close_ie方法时就可以关闭IE进程了。

 

TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-08  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 40374
  • 日志数: 76
  • 图片数: 2
  • 建立时间: 2007-11-02
  • 更新时间: 2011-08-13

RSS订阅

Open Toolbar