Thursday, August 18, 2011

Closes all instatnces of open IE browsers

Function Close_All_Browsers()

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colIEProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")

For Each objProcess in colIEProcessList
objProcess.Terminate()
Next
End Function

5 comments:

RAJAPUTRA said...

hi

Sreenu said...

Why is that much procedure needed to close all the opened IE browsers

Use simply -
SystemUtil.CloseByProcessName "iexplore.exe"

that's it..

RAJAPUTRA said...

You r Correct Sreenu.
But if you want to write your own method to close this is the way.

Unknown said...

I use • Close all IE browsers: SystemUtil.CloseProcessByName("iexplore.exe")

Anonymous said...

Both are different.
SystemUtil.CloseProcessByName("iexplore.exe")
It will throw a validation error if no instances are open in the above case.

But if the mentioned function is used. it will close all/any open instances .

About Me

My photo
Hi all,I am Arun Singh Rajaputra. I am working as a Project Lead in a reputed organization in Hyderabad, AP, India. I have little bit knowledge on Quick Test Professional and like to share my knowledge to all through this blog.

Subscribe to get updates on this blog

Enter your email address:

NOTE

Some of the posts posted in this blog are collected and most of them have been prepared by me. If any one have objections regarding any copied posts. Please mail me so that I can take a necessary action on that post.