Solved

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

Posted on 2003-11-03
5
627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
Six Sigma Control Plans

717 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