jscript, WHS, WScript-how to detect if IE instance exists

Hello Experts:
I have jscript code that uses WScript to create an instance of IE and navigates to a specific URL on the localhost:

objIE = WScript.CreateObject("InternetExplorer.Application);
objIE.Visible = 0;
objIE.Navigate("URL_ON_LOCALHOST");

I want to make it visible depending upon other conditions, but my big problem is that I don't want to create another one if objIE already exists

How can I detect if objIE already exists?  Also where can I find a list of properties, such as the Navigate and Visible?  I tried objIE.Exists, hoping, but that is not one of them.  All I find searching is VB examples.

Also I have tried if(objIE) {
.....
}
 but this just stops the script execution..  

This is jscript, on Windows XP.

Please help!!!!!
Thanks!
Myra
mdolleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
0
Michel PlungjanIT ExpertCommented:
An I suggest you do

var objIE=null; // make it global

function getIE() {
    if (objIE == null) objIE = WScript.CreateObject("InternetExplorer.Application);
    return objIE;
}


and use it later for example:

function something() {
  objIE = getIE(); // gets existing or creates a new
  objIE.Visible = 0;
  objIE.Navigate("URL_ON_LOCALHOST");
}

in function something, the name of the object does not need to be objIE:


function something() {
  myIE = getIE(); // gets existing or creates a new
  myIE.Visible = 0;
  myIE.Navigate("URL_ON_LOCALHOST");
}
 

will work too
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

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.