Solved

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

Posted on 2003-11-03
5
622 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

16 Experts available now in Live!

Get 1:1 Help Now