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

Posted on 2007-10-10
Last Modified: 2008-01-09
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;

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!!!!!
Question by:mdolle
    LVL 63

    Assisted Solution

    LVL 75

    Accepted Solution

    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;

    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;

    will work too

    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

    Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 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

    20 Experts available now in Live!

    Get 1:1 Help Now