Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to close all browsers
#4
Solved: 10 Years, 9 Months, 3 Weeks ago
The following function closes all IE Browser instnces qucikly...!!

' This function closes down all IE browser instances - quickly!
'Parameters: None
'Returns: True

Public Function CloseAllIEBrowsers()

' Windows Management Instrumentation (WMI) is the infrastructure for management data
' and operations on Windows-based operating systems. You can write WMI scripts or
' applications to automate administrative tasks on remote computers but WMI also supplies
' management data to other parts of the operating system and products, for example System
' Center Operations Manager, formerly Microsoft Operations Manager (MOM), or Windows
' Remote Management (WinRM).

' This technique shuts down the processes (as seen in the Task Manager) instead of
' closing the actual window using its handle. Close all IE Browsers using WMI:

' I used this technique as it seemed more reliable and consistent than other approaches.

Code:
strSQL = "Select * From Win32_Process Where Name = 'iexplore.exe'"

    Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set ProcColl = oWMIService.ExecQuery(strSQL)

    For Each oElem in ProcColl
        oElem.Terminate
    Next

    Set oWMIService = Nothing[size=small]

    CloseAllIEBrowsers = True
    
End Function

Thanks,
Reply


Messages In This Thread
How to close all browsers - by bangla123 - 11-09-2010, 03:48 AM
RE: How to close all browsers - by rajeshwar - 11-09-2010, 09:14 AM
RE: How to close all browsers - by bangla123 - 11-09-2010, 09:40 AM
RE: How to close all browsers - by UFTEnthusiast - 01-04-2011, 07:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Maximize and Close a Browser mv8167 4 16,094 03-26-2023, 03:55 PM
Last Post: Mike B
  Close popup ad windows dustwynn 1 2,765 10-25-2016, 05:57 PM
Last Post: Ankur
  [UFT] Close opened folder robertosalemi 1 3,167 02-10-2016, 07:06 PM
Last Post: robertosalemi
  Close browser code not working akilamurugesh 1 4,475 08-26-2014, 03:21 PM
Last Post: vinod123
  Close on Exit Issue in QTP 11.0 EGBELL 1 3,071 02-02-2014, 03:39 PM
Last Post: EGBELL

Forum Jump:


Users browsing this thread: 1 Guest(s)