Aaron Martin
Aaron Martin

Reputation: 397

How can I disable proxy via PowerShell when modifying registry does not work?

I am uninstalling an application which due to a bug sometimes enables the Windows Proxy setting in Windows 10. The PCs are distributed globally so I need to schedule a task to trigger after the uninstall (in case proxy gets enabled and network connection is lost) to check if the proxy is enabled then turn it off.

I have run the PowerShell code below to edit the registry while testing, and have found no other method to achieve this.

I have made sure all browsers are closed, I have refreshed services, and I have power cycled the machine.

Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value ""
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -Value 0

I have confirmed that the registry setting reflects the changes above, but the GUI (through Settings or through Internet Explorer) still shows the proxy enabled and the network connection remains down unless I manually uncheck the box.

Where are these proxy settings actually stored, there must be some other place besides the registry value that everyone refers to. When I set a value for a fake proxy and port, these setting remain in the GUI whether enabled or disabled until changed, but the registry settings are never updated to those values. These settings MUST reside elsewhere. Anyone know where?

Upvotes: 0

Views: 5064

Answers (2)

Carl Murphy
Carl Murphy

Reputation: 11

I had the same issue, but I had to also remove two registries. Then the proxy settings were disabled for my script to run.

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v SavedLegacySettings /f
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v DefaultConnectionSettings /f

Upvotes: 1

Aaron Martin
Aaron Martin

Reputation: 397

I found the answer. When running PowerShell and Regedit as an elevated user, the Current User context changes to that elevated user. The registry key needs to be edited under HKEY_USERS and then find the SID for the user in question and modify the entry there.

Upvotes: 0

Related Questions