Disclaimer / Clause de non-responsabilité / Haftungsausschluss:
Use of the code examples is at your own risk!
L’utilisation des exemples de code s’effectue à vos propres risques et périls !
Die Nutzung der Codebeispiele erfolgt auf eigenes Risiko!
Set Win 11 Proxy-Settings to: DIRECT - AutoDetectOFF - ScriptOFF
cls
#
#
# Disabled Proxy Script:
#
#
$Path = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
$Name = 'AutoConfigURL'
Function Disabled-ProxyScript {
if (Get-ItemProperty -ErrorAction SilentlyContinue -Path $Path -Name $Name) {
Remove-ItemProperty -ErrorAction SilentlyContinue -Path $Path -Name $Name
}
}
#
#
# Clear Proxy Settings:
#
#
Function Clear-ProxySettings {
# Set "Automatically detect settings"
Set-ItemProperty -ErrorAction SilentlyContinue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value 0
# Disable "Use setup script"
Set-ItemProperty -ErrorAction SilentlyContinue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyAutoConfigURL -Value ""
# Disable "Use a proxy server"
Set-ItemProperty -ErrorAction SilentlyContinue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -Value ""
}
#
#
# Disable 'Automatically detect proxy settings':
#
#
function Disable-AutomaticallyDetectProxySettings
{
# Read connection settings from Internet Explorer.
$regKeyPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\"
$conSet = $(Get-ItemProperty $regKeyPath).DefaultConnectionSettings
# Index into DefaultConnectionSettings where the relevant flag resides.
$flagIndex = 8
# Bit inside the relevant flag which indicates whether or not to enable automatically detect proxy settings.
$autoProxyFlag = 8
if ($($conSet[$flagIndex] -band $autoProxyFlag) -eq $autoProxyFlag)
{
# 'Automatically detect proxy settings' was enabled, adding one disables it.
# Write-Host "Disabling 'Automatically detect proxy settings'."
$mask = -bnot $autoProxyFlag
$conSet[$flagIndex] = $conSet[$flagIndex] -band $mask
$conSet[4]++
Set-ItemProperty -Path $regKeyPath -Name DefaultConnectionSettings -Value $conSet
}
$conSet = $(Get-ItemProperty $regKeyPath).DefaultConnectionSettings
if ($($conSet[$flagIndex] -band $autoProxyFlag) -ne $autoProxyFlag)
{
Write-Host "'Automatically detect proxy settings' is disabled."
}
}
# Reset Proxy Settings:
# netsh winhttp reset proxy
Write-Host "-__"
Disabled-ProxyScript
Reset-WinhttpProxy -Direct
Clear-ProxySettings
Disable-AutomaticallyDetectProxySettings
Write-Host
Write-Host "'Proxy Setup-Script' is disabled!"
Write-Host "-__"
Write-Host
Write-Host
pause