Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm looking for a way to programmatically either verify or overwrite the Automatic Configuration Script URL in IE's Internet Options-Connections-LAN Settings. A batch file would be easiest to work with, but since I'm not sure they are capable of doing that, VBS would be my next hope. Also, if there's a way to verify or set the checkboxes in the same window, that would be a useful bonus, but not essential. Thanks for any help anyone can give me on this!

Here's a C (or C++) application that I use in case some process changes my proxy URL, to reset it to the value that I want it to have:
#include <windows.h>int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
HKEY key;
LONG rc = RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
0,
KEY_ALL_ACCESS,
&key);
if (rc == 0)
RegSetValueEx(
key,
"AutoConfigURL",
0,
REG_SZ,
(const BYTE*) "http://put-your-hostname-here/proxy.pac",
sizeof "http://put-your-hostname-here/proxy.pac");return rc;
}I compile this into a less-than-2Kb .exe file and put it in my Startup folder. It is a pure Windows application. If you double-click on it, you may think it doesn't work. That's because it's lightning-fast and completes its job before you even notice it.
If you haven't got a C compiler, and need a solution in a different language, you can try using REG.exe in a batch file to do the same thing as above. Type REG /? for usage instructions.

I don't have access to a C compiler at work, but I might try it out at home and just bring the program in. I am curious if there is a way to actually populate the field in the LAN Settings window and apply it as opposed to changing the registry settings. (To explain: we have some systems that have the proxy URL entered via a "proxy.reg" file, but the actual field in LAN Settings remains blank, and the system doesn't use the URL even though we've verified it's been entered into the registry.)
Thanks for the info!

That's odd, when I change the value in the registry, it's immediately reflected in the LAN Settings window.

They are systems that have been locked down by all sorts of registry tweaks and other programs meant to modify settings, so I'm thinking they basically just made a complete mess of the registry, and this sort of problem is the result. Unfortunately, they can't make any changes to the work that was done previously, so I'm supposed to just work around them the best I can. I know that when we've changed the proxy URL manually, it's fixed the issue every time, so that's what I was hoping I could do automatically. Even just opening the window to that setting without making changes would be helpful since it would save time (these changes are done remotely, and sometimes on very slow connections).

The best I can come up with is the command
rundll32 shell32.dll,Control_RunDLL inetcpl.cpl,Internet,4
This opens Internet Settings and displays the 5th tab, which is the one containing the LAN Settings button. It would have been better if I could automatically open the LAN Settings dialog box, but I don't know if that's possible.

Here we go:
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "rundll32 shell32.dll,Control_RunDLL inetcpl.cpl,Internet,4"
Wscript.Sleep 1500
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{ENTER}"
objShell.SendKeys "{TAB}"
WScript.QuitUsing your command, this will open up the LAN Settings and put the selection on the "Use automatic configuration script" checkbox. This should be as close as I can get to what I need. Thanks for your help!!!

Thanks for that, now you've taught me something too! Your reply prompted me to read up on the use of SendKeys.
However, instead of sending six tabs and an Enter, I would send ALT+L like this:
objShell.SendKeys "%L"
This is because the number of tabs you need can vary. If you haven't got any connection settings, some of the buttons in that dialog box will be greyed out and the tab key will skip them. For example, on my machine, I only need 3 Tab presses to reach the LAN Settings button.

Very true! Plus, a smaller program that does the same job as a larger one is always preferable. You've been a tremendous help; I thank you again!

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |