Alex Essilfie Alex Essilfie - 1 year ago 332 Question

How to change LAN Settings (proxy configuration) programmatically

I am writing a program to automatically switch my proxy address based on the network I am connected to.

I have so far got everything to work except the part that I have highlighted below.

LAN Settings Dialog

Is there any way to change the automatic configuration script and the automatically detect settings in code?

The solution can be either P/Invoke registry editing. I just need something that works.

Answer Source

You can change proxy settings by using the registry. See the following link:

Key path: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings



A question in regarding how to disable automatically detect settings in ie proxy configuration. Disable "Automatically detect settings" in IE proxy configuration

A snippet, taken from Internet Explorer Automatic Configuration Script Definition via Registry.

Script 1: This enables the AutoConf Script and defines what it is (exchange the http://xxxx with your script)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]

Script 2: This script Disables the AutoConf Script and enables a proxy server with exceptions.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download