问题
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.
回答1:
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):
- Open Regedit
- Navigate to: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
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:
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"
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"
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:
来源:https://stackoverflow.com/questions/60946638/how-to-toggle-use-automatic-configuration-script-checkbox-in-ie-settings-witho