А АThursday, 20 October 2016

Automatically Detect Settings check in Internet Explorer.

Hi all.

As you know the check box "Automatically Detect Settings" in Internet Explorer is checked by default. You can uncheck it or make others connection settings manually. But often I need do it in automatical mode.

So, we choose way via Windows registry. For example, we can use VB-script. We need to change this value:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]
DefaultConnectionSettings (REG_BINARY).

This VB-script below allows you to turn off (or turn on) the "Automatically Detect Settings" check box in Internet Explorer:

Option Explicit
On Error Resume Next
'Create a constant for the HKEY_CURRENT_USER object
Const HKCU = &H80000001
'Define variables
Dim strComputer
Dim strRegistryKey
Dim objRegistry
Dim strRegistryValue
Dim binValue
strComputer = "."
strRegistryKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
strRegistryValue = "DefaultConnectionSettings"
'Connect to the Registry
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
'Retrieve the current settings.
objRegistry.GetBinaryValue HKCU, strRegistryKey, strRegistryValue, binValue
'Change the 'Automatically detect settings' box to unticked
binValue(8) = 05  '5=4+1
'or binValue(8) = 13 '13=8+4+1 enable this line to check the box instead of Uncheck
'Save the changes
objRegistry.SetBinaryValue HKCU, strRegistryKey, strRegistryValue, binValue

How can you calculate this value? You have to know the following values by operations:
  • Automatically Detect Settings – 8
  • Use Automatic Configuration Script – 4
  • Use a Proxy Server for LAN – 2

The values after each item above are their numeric representation. And one note - you need to add 1 to the final value though!

So, for example, to set "Auto Detect" and "Use Proxy Server" set the value in binValue(8) above to 0B, the hex equivalent of  decimal 11 (i.e. 11=8+2+1).

Is it clear? Sure.  Except for me one item - why these both operations "Auto Detect" and "Use Proxy Server" not exclude one another? It will be logically.

No comments:

Post a Comment

А что вы думаете по этому поводу?

Версия на печать