[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2003-11-03
5
Medium Priority
?
632 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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 …
Simple Linear Regression

830 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