We help IT Professionals succeed at work.
Get Started

Need help to add additional code to JS script regarding IE connection programming

Rexx
Rexx asked
on
319 Views
Last Modified: 2010-04-17
I'm am currently using js script between the *s below as follows:

*************************************************************************************************************************************

function KillIE()
{    
     var shell = new ActiveXObject("Shell.Application");
    var wins = shell.Windows();
    var e = new Enumerator(wins);
    for (; !e.atEnd(); e.moveNext())
     {
         try
         {
              if(e.item().Document)
                   e.item().Quit();
             
          }catch(ex){}
   }                        
}

function ToggleProxy()
{
    var KeyName = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable";
    var WshShell = new ActiveXObject("WScript.Shell");

    var ProxyEnabled = WshShell.RegRead(KeyName);
    var newValue = ProxyEnabled ? 0 : 1;

 
    WshShell.RegWrite(KeyName,newValue,"REG_DWORD");

    if(newValue == 0)
    {
          newValue = "IE set for Office";
    }
    else if(newValue == 1)
    {
          newValue = "IE set for Home";
    }
   
    WScript.Echo(newValue);
}

function LoadIE()
{
    var IE = new ActiveXObject("InternetExplorer.Application");
    IE.Visible = false;
}

KillIE();
ToggleProxy();
LoadIE();

*************************************************************************************************************************************

What this script does is toggle Internet Explorer (IE) Connections/LAN Settings/Proxy server either on or off.

The code I need to add/modify to the code above is to toggle between 1 of 2 ways as follows:

(1) Check mark both "Use a proxy server ... " and "Bypass proxy server ... " then add the appropriate IP address and Port to each server type.
(2) Check mark only "Use a proxy server ... " then add the appropriate IP address and Port to each server type.


Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE