Solved

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

Posted on 2003-11-03
5
623 Views
Last Modified: 2013-11-13
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.
Thanks.
0
Comment
Question by:alibabas
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 9674392
If you KNOW FOR SURE the window title, then

hwin=FindWindow("MyTitle",NULL)
DestroyWindow(hwin)

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:
http://www.systeminternals.com/ntw2k/freeware/pslist.shtml

with the tree option set to find which iexplore is a child of yours.
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 50 total points
ID: 9676932
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 "www.google.com
IE.visible=1 ' ignore this line if you dont want the browser to be visible  
' let the page load
Do while IE.busy
loop
Do While UCase(IE.Document.readyState) <> "COMPLETE"
      WScript.Sleep 100
   DoEvents
Loop
'now close ie
IE.Quit
set IE=nothing
'code ends

if you want you can write the code in a vb application too
0
 

Author Comment

by:alibabas
ID: 9678763
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.
0
 

Author Comment

by:alibabas
ID: 9679919
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.

0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9684152
Glad to be of help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now