1

I need to switch on the proxy to use internet and switch it off for office intranet. Manually it is tiresome. The proxy does not change. How to just toggle the check box using bat file? If the status is enabled it will disable and if disable it will enable. Nothing much. Don't want to clear the proxy string. Just enabling/disabling the checkbox.

Abhishek Bali
  • 11
  • 1
  • 4
  • 1
    Does this answer your question? [Batch File to disable internet options proxy server](https://stackoverflow.com/questions/18439373/batch-file-to-disable-internet-options-proxy-server) – Gerhard Mar 31 '20 at 08:57

1 Answers1

2

As far as I know, generally, toggle the 'Use Automatic Configuration script' checkbox will not clear the proxy server address. But it might clear the Address under the 'Use Automatic Configuration script' checkbox, so, I suppose you want to keep the Address when toggle the 'Use Automatic Configuration script' checkbox. If that is the case, please check the following steps:

After adding the Address from IE setting, please refer to the following steps to check the registry setting about the Use Automatic Configuration script Setting, and get the DefaultConnectionSettings data (the data contain the address):

  1. Open Regedit
  2. Navigate to: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
  3. check the "DefaultConnectionSettings"

    The 9th bit of this key controls the setting.

    01 - Nothing is checked ("Automatically detect settings" or "Use automatic configuration script")

    05 - Only "Use automatic configuration script" is checked

    09 - Only "Automatically detect settings" is checked

    0d - Both are checked

    After adding the Address under the "Use automatic configuration script", we can see the DefaultConnectionSettings data contains the address, please check the following screenshot:

    enter image description here

  4. Modify above data and close Internet Explorer, and then open the IE browser again to verify the change has taken effect.

To checked/unchecked the "Use automatic configuration script", we could run the following commands using the Command Prompt to change the setting.

Unchecked the option and keep address:

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /f /v "DefaultConnectionSettings" /t REG_BINARY /d "460000000400000009000000000000000000000026000000687474703A2F2F7777772E78787878782E636F6D3A313233342F73616D706C6553637269707400000000000000000000000000000000"

enter image description here

Checked the checkbox and set address:

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /f /v "DefaultConnectionSettings" /t REG_BINARY /d "46000000040000000d000000000000000000000026000000687474703A2F2F7777772E78787878782E636F6D3A313233342F73616D706C6553637269707400000000000000000000000000000000"

enter image description here

Edit:

You could also use a bat file with the above command, like this:

@echo off

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /f /v "DefaultConnectionSettings" /t REG_BINARY /d "46000000040000000d000000000000000000000026000000687474703A2F2F7777772E78787878782E636F6D3A313233342F73616D706C6553637269707400000000000000000000000000000000"

Besides, if you want to set the Proxy Server Address via the DefaultConnectionSettings key, please refer to the following command (you could check the DefaultConnectionSettings data from the Registry):

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /f /v "DefaultConnectionSettings" /t REG_BINARY /d "46000000090000000F000000100000007777772E78787878782E636F6D3A38300000000026000000687474703A2F2F7777772E78787878782E636F6D3A313233342F73616D706C6553637269707400000000000000000000000000000000"

After running above command, the result like this:

enter image description here

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • This script changes the address to the address in your settings ('www.xxxxx.com etc") – karu Mar 15 '21 at 08:44
  • I just changed my settings the way I wanted them to be, extracted the registry key, and scripted an import of the extracted key. – n8. Aug 29 '23 at 20:05