買了一個穿越防火牆的代理,在 Windows 下每次手動設置代理都好麻煩,最後不斷嘗試 Powershell 來設置,最後也終於成功了。shell
其實利用 Powershell 來設置 IE 的代理,就是更改的註冊表,先貼代碼:
$enableProxy=Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable
if($enableProxy.ProxyEnable -eq 1)
{
Write-Host "IE proxy is disabled"
Set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -value 0
Set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "AutoConfigURL" -value ""
}
else
{
Write-Host "IE proxy is enabled"
Set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -value 1
#代理方法一:自動配置腳本和
Set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "AutoConfigURL" -value "http://121.199.52.48:3389/sample/111.pac"
#代理方法二:設置代理服務器
#Set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyServer" -value "192.168.75.80:808"
}
sleep 3
關於 註冊表中IE 的屬性可編輯的共有: