• 0

[VB.NET] Setting Internet Explorer Proxy Settings


Question

I have this plugin-based application where one of the plugins, it's supposed to change IE proxy settings. I'm doing this via registry, and all the values are changed according to the real settings. The keys/values I changed are the ones that IE changes when you enable/disable the proxy server as I took screenshots of both the registry states, before and after applying a proxy server.

However, this is not really working. As I said, the values change (to enable or disable depending on what we want) but the checkbox on Internet Explorer settings doesn't change. Well, if the proxy is really enabled and I want to disable it, it works, the checkbox is unmarked, but if the checkbox is not marked and I try to enable it with my code, all values change but the checkbox remains unchecked.

Here's the code:

Public Sub EnableProxy()
		If objHost.DirectConnection = False Then
			Dim regKey As RegistryKey

			regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

			regKey.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
			regKey.SetValue("ProxyServer", objHost.ProxyAddress.ToString + ":" + objHost.ProxyPort.ToString, RegistryValueKind.String)

			If objHost.BypassLocal Then
				regKey.SetValue("ProxyOverride", "<local>", RegistryValueKind.String)
			Else
				regKey.DeleteValue("ProxyOverride", False)
			End If

			regKey.Close()
		Else
			MessageBox.Show("Networkcher is currently not configured to use a proxy server. " + ControlChars.CrLf + _
							"Please open Network Switcher settings dialog and configure the proxy server.", "Missing proxy settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
		End If
	End Sub

	Public Sub DisableProxy()
		Dim regKey As RegistryKey

		regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

		regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)

		regKey.Close()
	End Sub

I would really appreciate any help on this...

3 answers to this question

Recommended Posts

  • 0
  Nazgulled said:
I have this plugin-based application where one of the plugins, it's supposed to change IE proxy settings. I'm doing this via registry, and all the values are changed according to the real settings. The keys/values I changed are the ones that IE changes when you enable/disable the proxy server as I took screenshots of both the registry states, before and after applying a proxy server.

However, this is not really working. As I said, the values change (to enable or disable depending on what we want) but the checkbox on Internet Explorer settings doesn't change. Well, if the proxy is really enabled and I want to disable it, it works, the checkbox is unmarked, but if the checkbox is not marked and I try to enable it with my code, all values change but the checkbox remains unchecked.

Here's the code:

Public Sub EnableProxy()
		If objHost.DirectConnection = False Then
			Dim regKey As RegistryKey

			regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

			regKey.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
			regKey.SetValue("ProxyServer", objHost.ProxyAddress.ToString + ":" + objHost.ProxyPort.ToString, RegistryValueKind.String)

			If objHost.BypassLocal Then
				regKey.SetValue("ProxyOverride", "<local>", RegistryValueKind.String)
			Else
				regKey.DeleteValue("ProxyOverride", False)
			End If

			regKey.Close()
		Else
			MessageBox.Show("Networkcher is currently not configured to use a proxy server. " + ControlChars.CrLf + _
							"Please open Network Switcher settings dialog and configure the proxy server.", "Missing proxy settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
		End If
	End Sub

	Public Sub DisableProxy()
		Dim regKey As RegistryKey

		regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

		regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)

		regKey.Close()
	End Sub

I would really appreciate any help on this...

Are you restarting internet explorer before checking for the check box?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Ah so it's not in the .ISO it's self but it changes the definition in the OOBE update during setup?
    • They always have. This just updates what's included out of the box during the initial install.
    • So basically their prebuilding it into the ISOs?
    • Microsoft shares Defender anti-virus update for new Windows 11/10 ISOs by Sayan Sen Following the one for Lumma last month, Microsoft has also published a new Defender update for Windows 11/10/Server installation images this month. This update package is necessary as a Windows installation image may contain old, outdated anti-malware definitions and software binaries. Aside from better security, these updates can also provide improved performance benefits in some cases. When a new Windows installation is set up, there may be a temporary security risk due to outdated Microsoft Defender protection in the OS installation images. This happens because the antimalware software included in these images might not be up to date. Thus Microsoft says that these updated definitions essentially help close this protection gap. Microsoft delivered the latest security definitions for Windows images via security intelligence update version 1.431.54.0. The Defender package version is also the same. It applies to Windows 11, Windows 10 (Enterprise, Pro, and Home editions), Windows Server 2022, Windows Server 2019, and Windows Server 2016. Microsoft writes: From Microsoft's security bulletin, we learn that the security intelligence update version 1.431.54.0 was released this past week adds threat detections for various backdoor exploits, trojans, among others. For those wondering, the latest intelligence update is version 1.431.155.0 at the time of writing.
    • “In other news about OneDrive frustration, Microsoft recently locked out a user who was attempting to move a bunch of important data from old hard drives to OneDrive.” - It was probably CSMA..
  • Recent Achievements

    • One Month Later
      SekTheFirst earned a badge
      One Month Later
    • First Post
      zayanhani earned a badge
      First Post
    • First Post
      HarryTaylor earned a badge
      First Post
    • One Year In
      Eternal Tech earned a badge
      One Year In
    • One Month Later
      Eternal Tech earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      650
    2. 2
      ATLien_0
      229
    3. 3
      Michael Scrip
      224
    4. 4
      Steven P.
      141
    5. 5
      +FloatingFatMan
      139
  • Tell a friend

    Love Neowin? Tell a friend!