How to change proxy settings using script

There are so many computer tricks and shortcuts available today, that help us to do the things very quickly, effectively and save our time. We prefer to use these tricks and scripts because we all know that these save our time and time is money. So, rather than doing the things manually, we can save our time by running scripts and using shortcuts and can enhance our performance and also get better results. There are lot of scripts available for doing different tasks and these are really very useful and awesome.

Today, we will discuss about some scrips related to proxy settings of your PC, that are available in LAN settings of browser. Let’s assume that there is a person who is working in an office, where proxy is being used for internet connection and he is providing with a laptop and also allowed to carry his laptop with him. So, in the office, he has to enable proxy settings to use internet. But, in his home, there is no proxy activated for his internet connection. So in this scenario, he has to enable proxy settings during his office hours but in his home every time he has to disable this proxy to use internet.  It seems to be very irritating or difficult for a user to enable or disable these settings manually each time. Here with the help of these scripts we can change the value of proxy server, either enable or disable proxy server and also can bypass proxy server for local addresses very quickly and easily.

So let’s start now.

Here note that you need to change these settings in any of two browsers internet explorer or google chrome, other will automatically get updated, means you need not to change settings in both browsers, if you make changes in internet explorer, chrome will get updated automatically and if you make changes in google chrome, internet explorer automatically gets updated.

I will show you where you can find these proxy settings in your browser. I will show you these settings in two browsers – internet explorer and google chrome.

First, I will show you in internet explorer.

Open internet explorer, click on settings icon and then click on internet options.

image on how to open internet options in browser

There you will find new windows named internet options opens on your screen.

internet options

Now go to connections tab and click on LAN settings.

opening proxy settings

There you will find a new dialogue box named Local Area Network (LAN) Settings.

lan settings

Here if you find option automatically detect settings as checked, mark it is unchecked.

This way you will find your proxy server settings in internet explorer.

In google chrome, it is also very simple to find proxy settings, just open google chrome, click on settings icon and then click on settings.

settings google chrome

Now a new page named settings gets opened before you, there in search box type proxy, beneath this you will be able to see open proxy settings options, click on it. Internet properties will be opened before you.

proxy settings

There click on LAN settings, a new dialogue box named Local Area Network (LAN) Settings will be opened before you, there you can find proxy server.

google proxy

As mentioned above, if automatically detect settings is already checked, uncheck it.

 

Now we will proceed to change these settings with the help of script.

First case is assuming that we have no proxy enabled in our browser, as displayed in above picture.

So we will enable it and give it also an address 192.168.0.1 and port no. 8080, you can put IP and port number according to your requirements.

So, for creating a script, open notepad and copy below mentioned lines (from @echo to <local>" /f) in your notepad:

@ECHO OFF

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d 192.168.0.1:8080 /f

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "192.168.*;<local>" /f

 

 

Note: First registry setting is to enable proxy, second is to provide address and port number and third is to enable bypass proxy server for local addresses option. First two entries are mandatory, third is upto your requirement. If you want to bypass, leave it as it is and if you don’t require bypass option, remove third line. I am highlighting first two in green and third in red, for your convenience, in below image.

enable and bypass proxy

Now save this notepad with .bat extension with any name you want to, here I am saving it as enableproxy.bat, but please make sure that save as type option should be selected as All files (*.*).

saving enable proxy

Now we are creating a script to disable proxy in same way, open a new notepad and just copy and paste below code to your notepad (from @ECHO to /d 0 /f).

@ECHO OFF

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d 0 /f

 

 

 

Note: First registry setting is for disabling proxy and second registry setting is for removing tick from bypass proxy server for local addresses option.

Save this file with your desired name but with .bat extension, here I am saving it as disableproxy.bat but make sure save as type should be selected as All files (*.*).

saving disable proxy

Now you will be able to see both files in the location, where you have saved them. First we will run enableproxy.bat file and see the changes in proxy settings, as:

enabled proxy in browser

Now we will run disableproxy.bat file to check if it is working fine. After running file, you will find your browser settings as:disabled proxy in browser

So we have completed the task successfully.

Note: If you are working in chrome browser, you can change state of proxy settings of that browser if the chrome is already running, you can run both files to enable or disable proxy and can be able to change the state of proxy. But in Internet Explorer, you can’t change the state of proxy if browser is already running, if you run the file you have to close and reopen the browser, so that it can take effect, otherwise it will not take effect until you restart the browser. So if you are using internet explorer browser, before running any script, close it. Also check on other browsers, that you are using.

Thank You.

Note: For our more articles or blogs please visit the Blog link of our website.

Leave a Reply

Your email address will not be published. Required fields are marked *