What key in windows registry disables IE connection parameter “Automatically Detect Settings”?

后端 未结 11 1752
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 18:15

I\'m trying to set all the connection settings in IE.

I\'ve found how to modify most of them, in the path :

HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\

相关标签:
11条回答
  • 2020-12-04 18:52

    Another way to control this setting is by using an undocumented registry key AutoDetect=0 mentioned on this blog post:

    Registry Key : HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\

    DWORD AutoDetect = 0 or 1

    So the .reg file to turn it off would look like:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
    "AutoDetect"=dword:00000000
    
    0 讨论(0)
  • 2020-12-04 18:52

    I have used a combined answer and made a powershell script which does the trick for you

    $name = $PSScriptRoot + "\" + $MyInvocation.MyCommand.Name
    
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$name`"" -Verb RunAs; exit }
    
    $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
    
    $Name = "AutoDetect"
    
    $value = "0"
    
    New-ItemProperty -Path $registryPath -Name $name -Value $value ` -PropertyType DWORD -Force | Out-Null
    
    Read-Host -Prompt "press Enter to Continue"
    

    The script will run as admin and the change the value to 0 ( Disable the Auto-Detect ).

    0 讨论(0)
  • 2020-12-04 18:58

    I found the solution : it's the 9th byte of this key :

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections] "DefaultConnectionSettings"=hex:3c,00,00,00,1f,00,00,00,05,00,00,00,00,00,00, 00,00,00,00,00,00,00,00,00,01,00,00,00,1f,00,00,00,68,74,74,70,3a,2f,2f,31, 34,34,2e,31,33,31,2e,32,32,32,2e,31,36,37,2f,77,70,61,64,2e,64,61,74,90,0e, 1e,66,d3,88,c5,01,01,00,00,00,8d,a8,4e,9e,00,00,00,00,00,00,00,00

    It's a bitfield:

    • 0x1: (Always 1)
    • 0x2: Proxy enabled
    • 0x4: "Use automatic configuration script" checked
    • 0x8: "Automatically detect settings" checked

    Mask 0x8 to turn it off, i.e., subtract 8 if it's higher than 8.

    Thanks to Jamie on google groups.

    Update

    Based on the VBScript by WhoIsRich combined with details in this answer, here's a PowerShell script to amend these & related settings:

    function Set-ProxySettings {
        [CmdletBinding()]
        param ( #could improve with parameter sets 
            [Parameter(Mandatory = $false)]
            [bool]$AutomaticDetect = $true
            ,
            [Parameter(Mandatory = $false)]
            [bool]$UseProxyForLAN = $false
            ,
            [Parameter(Mandatory = $false)]
            [AllowNull()][AllowEmptyString()]
            [string]$ProxyAddress = $null
            ,
            [Parameter(Mandatory = $false)]
            [int]$ProxyPort = 8080 #closest we have to a default port for proxies
            ,
            [AllowNull()][AllowEmptyString()]
            [bool]$UseAutomaticConfigurationScript = $false
        )
        begin {
            [string]$ProxyRegRoot = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
            [string]$DefaultConnectionSettingsPath = (Join-Path $ProxyRegRoot 'Connections')
            [byte]$MaskProxyEnabled = 2
            [byte]$MaskUseAutomaticConfigurationScript = 4
            [byte]$MaskAutomaticDetect = 8
            [int]$ProxyConnectionSettingIndex = 8
        }
        process {
        #this setting is affected by multiple options, so fetch once here 
        [byte[]]$DefaultConnectionSettings = Get-ItemProperty -Path $DefaultConnectionSettingsPath -Name 'DefaultConnectionSettings' | Select-Object -ExpandProperty 'DefaultConnectionSettings'
    
        #region auto detect
        if($AutomaticDetect) { 
            Set-ItemProperty -Path $ProxyRegRoot -Name AutoDetect -Value 1
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -bor $MaskAutomaticDetect
        } else {
            Set-ItemProperty -Path $ProxyRegRoot -Name AutoDetect -Value 0
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -band (-bnot $MaskAutomaticDetect)
        }
        #endregion
    
        #region defined proxy
        if($UseProxyForLAN) {
            if(-not ([string]::IsNullOrWhiteSpace($ProxyAddress))) {
                Set-ItemProperty -Path $ProxyRegRoot -Name ProxyServer -Value ("{0}:{1}" -f $ProxyAddress,$ProxyPort)
            }
            Set-ItemProperty -Path $ProxyRegRoot -Name ProxyEnable -Value 1
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -bor $MaskProxyEnabled
        } else {
            Set-ItemProperty -Path $ProxyRegRoot -Name ProxyEnable -Value 0        
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -band (-bnot $MaskProxyEnabled)
        }
        #endregion
    
        #region config script
        if($UseAutomaticConfigurationScript){
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -bor $MaskUseAutomaticConfigurationScript
        }else{
            $DefaultConnectionSettings[$ProxyConnectionSettingIndex] = $DefaultConnectionSettings[$ProxyConnectionSettingIndex] -band (-bnot $MaskUseAutomaticConfigurationScript) 
        }
        #endregion
    
        #persist the updates made above
        Set-ItemProperty -Path $DefaultConnectionSettingsPath -Name 'DefaultConnectionSettings' -Value $DefaultConnectionSettings
        }
    }
    
    0 讨论(0)
  • 2020-12-04 18:59

    I'm aware that this question is a bit old, but I consider that my small update could help other programmers.

    I didn't want to modify WhoIsRich's answer because it's really great, but I adapted it to fulfill my needs:

    1. If the Automatically Detect Settings is checked then uncheck it.
    2. If the Automatically Detect Settings is unchecked then check it.

      On Error Resume Next
      
      Set oReg   = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
      sKeyPath   = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
      sValueName = "DefaultConnectionSettings"
      
      ' Get registry value where each byte is a different setting.
      oReg.GetBinaryValue &H80000001, sKeyPath, sValueName, bValue
      
      ' Check byte to see if detect is currently on.
      If (bValue(8) And 8) = 8 Then
          ' To change the value to Off.
          bValue(8) = bValue(8) And Not 8
      ' Check byte to see if detect is currently off.
      ElseIf (bValue(8) And 8) = 0 Then
          ' To change the value to On.
          bValue(8) = bValue(8) Or 8
      End If
      
      'Write back settings value
      oReg.SetBinaryValue &H80000001, sKeyPath, sValueName, bValue
      
      Set oReg = Nothing
      

    Finally, you only need to save it in a .VBS file (VBScript) and run it.

    0 讨论(0)
  • 2020-12-04 19:02

    You can always just export the registry, change the setting, then export the registry again and do a diff.

    0 讨论(0)
  • 2020-12-04 19:04

    Indeed, the 9th byte indicates the check state of the button, but the answers above don't take into account the checkbox which enables manual configuration. This check state value is also present in this ninth byte. The real answer should thus be:

    Byte value

    00001001 = Manual proxy is checked

    00000101 = Use automatic configuration script is checked

    00000011 = Automatically detect settings is checked

    When multiple checkboxes are checked, the value of the 9th byte is the result of the bitwise OR operation on the values for which the checkbox is checked.

    0 讨论(0)
提交回复
热议问题