简体   繁体   English

Powershell-更改Proxyserver的注册表项

[英]Powershell - changing registry entry for Proxyserver

I have a script that changes the internet proxy server. 我有一个更改Internet代理服务器的脚本。 It is under HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyServer . 它位于HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyServer The problem is, I seem to have to wait a while for the change to be reflected (so I can use the browser) or go into the Internet Options in Windows and click on Connections and open the Lan Settings and click Ok. 问题是,我似乎需要等待一段时间才能反映出更改(以便可以使用浏览器),或者进入Windows中的“ Internet选项”,然后单击“连接”并打开“局域网设置”,然后单击“确定”。

Is there something else I can do in my script to make the proxy reflected immediately in my browser? 我可以在脚本中做其他事情来使代理立即反映在浏览器中吗? Closing and opening the browser doesn't seem to make it happen either. 关闭和打开浏览器似乎也没有实现。

I mostly use Chrome, but have the same issue with IE. 我主要使用Chrome,但是IE也有同样的问题。

I do not experience any delay on Win8.1 with IE and Firefox, did you try it this way ? 我在使用IE和Firefox的Win8.1上没有遇到任何延迟,您是否以此方式尝试过?

Close the browsers before making the change. 进行更改之前 ,请关闭浏览器。

$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

#Enable proxy
Set-ItemProperty -Path $regPath -Name "ProxyEnable" -Value 1
Set-ItemProperty -Path $regPath -Name "ProxyServer" -Value "proxy.domain:1080"

#Disable proxy
Set-ItemProperty -Path $regPath -Name "ProxyEnable" -Value 0
Set-ItemProperty -Path $regPath -Name "ProxyServer" -Value ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM