Q&A Monday: Enable and Disable Proxy via Scripts

Question:

I use my laptop both inside and outside of my company’s network.  It is a company issued laptop and when I am in the office, I am suppose to use their proxy server, when I am out on the road, I’m suppose to use the local connection, which does not have a proxy.  Currently I go into internet settings and enable or disable  the proxy server as needed, what I am looking for is a simpler way to this.  Please help me

Christopher  Sheppard
Northampton, PA

Answer:

While looking into the proxy settings in the Internet Options, I was able to trace it down to a couple of registry settings, but once set up you only need to make a single change to a key.  This key resides in the following place:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings in the ProxyEnable key.

If the key is equal to 1 the proxy setting is enabled (checked) and if it’s 0 the proxy is disabled (unchecked)

*NOTE: As with all registry changes, make sure you know what you are doing, and wrong changes can mess up your computer.  Also make sure you backup you registry prior to making any changes*

 

So to start making an easy to run script, you need to open notepad, and create a registy entry like so:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
“ProxyEnable”=dword:00000001

save the file as ProxyEnable.reg (the name doesn’t matter, but the .reg does matter), then open a new notepad and paste the following into it:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
“ProxyEnable”=dword:00000000

save the file as ProxyDisable.reg

Now, you can put these on your desktop and import the change, to go from Proxy to without, with only a single icon for each.  If you have another way to do this please let me know, but this is a simple and clean way of quickly switching without going into internet settings.

——————————————————————————————–
If you have any questions that you want Jim to answer, from business servers to home computers, drop him a line at me@jimguckin.com, and he’ll try to answer your question. Check back every Monday for a new Question and Answer session, and during the rest of the week for his other technical insights.

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.