Skip to content

Instantly share code, notes, and snippets.

@famousgarkin
Last active July 24, 2024 17:04
Show Gist options
  • Save famousgarkin/c5138b1e13ac41920d22 to your computer and use it in GitHub Desktop.
Save famousgarkin/c5138b1e13ac41920d22 to your computer and use it in GitHub Desktop.
PowerShell Set-Proxy, Clear-proxy
# NOTE: registry keys for IE 8, may vary for other versions
$regPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
function Clear-Proxy
{
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0
Set-ItemProperty -Path $regPath -Name ProxyServer -Value ''
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value ''
[Environment]::SetEnvironmentVariable('http_proxy', $null, 'User')
[Environment]::SetEnvironmentVariable('https_proxy', $null, 'User')
}
function Set-Proxy
{
$proxy = 'http://example.com'
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxy
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value '<local>'
[Environment]::SetEnvironmentVariable('http_proxy', $proxy, 'User')
[Environment]::SetEnvironmentVariable('https_proxy', $proxy, 'User')
}
@iamliuzy
Copy link

How do I execute this code?

https://www.youtube.com/watch?v=ZnTffdLnIqs

@omaidb
Copy link

omaidb commented Apr 15, 2022

我试过了powershell只能使用http代理,不能使用socks5代理.
大佬,有powershell配置socks5的方法吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment