Win 2000 - open up URL in IE and then close down IE

I am writing a small app to startup a IE witha specified URL.  this URL will initiate processes and that is all I need to do with this URL. I have this part down, but I need to close down the browser (probably IE) window that the Open URL call opens up.
I was told it can be done through API calls, but you need the handle. I am not sure how to do this. can anyone give me some direction.
Who is Participating?
bhagyeshtConnect With a Mentor Commented:
save the code below as a vbs file and you are done. change the url from google to what ever you want
double click to execute.
'code start
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "
IE.visible=1 ' ignore this line if you dont want the browser to be visible  
' let the page load
Do while IE.busy
Do While UCase(IE.Document.readyState) <> "COMPLETE"
      WScript.Sleep 100
'now close ie
set IE=nothing
'code ends

if you want you can write the code in a vb application too
If you KNOW FOR SURE the window title, then


Otherwise, you'll have to get the process ID (pid).

If you created it with CreateProcess(), you already have the PID.  If not, a simple way to get the pid is to shell out a PULIST and parse its output to get the pid foe iexplore.exe.

Once you have the pid, get a handle to the procees with OpenProcess() the kill it with TerminateProcess().

This approach is no good if there are multiple instances of iexplore.exe.

The work way to get it if that's the case is to shell out a PSLIST
available here:

with the tree option set to find which iexplore is a child of yours.
alibabasAuthor Commented:
I will try both methods and award the points to the person whose solution worked best for me.. Hope that is fair.
And Thank you for yuor assistance.
alibabasAuthor Commented:
Thank you both...
With the code provide by bhagyesht, it made more sense as I found out that locking down the name/titel.. to one is not possible.  
too many unknowns with cookre suggestion from my end.  Thanks cookre for the suggestion.. will use it in other areas.

Glad to be of help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.