I need to enable/disable IE proxy settings while IE is running. I have a PowerShell script line to enable the proxy:
Set-ItemProperty -Path "Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyEnable -value 1
or this to disable:
Set-ItemProperty -Path "Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyEnable -value 0
Above scripts work, registry key gets updated. However, IE doesn't pick up the value until I close all the open IE windows and open a new one. I need already opened/running IE windows to pick up the new setting.
Would there be any way to achieve what I want?
This question is related to
windows
internet-explorer
powershell
registry
I know this is an old question, however here is a simple one-liner to switch it on or off depending on its current state:
set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -value (-not ([bool](get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable).proxyenable))
The problem is that IE won't reset the proxy settings until it either
Below is the code that I've used to get this working:
function Refresh-System
{
$signature = @'
[DllImport("wininet.dll", SetLastError = true, CharSet=CharSet.Auto)]
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
'@
$INTERNET_OPTION_SETTINGS_CHANGED = 39
$INTERNET_OPTION_REFRESH = 37
$type = Add-Type -MemberDefinition $signature -Name wininet -Namespace pinvoke -PassThru
$a = $type::InternetSetOption(0, $INTERNET_OPTION_SETTINGS_CHANGED, 0, 0)
$b = $type::InternetSetOption(0, $INTERNET_OPTION_REFRESH, 0, 0)
return $a -and $b
}
modifying the proxy value under
[HKEY_USERS\<your SID>\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
doesnt need to restart ie
Source: Stackoverflow.com