Computing.Net > Forums > Programming > Verify Proxy.pac

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Verify Proxy.pac

Reply to Message Icon

Name: keridbey
Date: March 17, 2008 at 08:37:48 Pacific
OS: Win2000
CPU/Ram: 1.5 Ghz / 512 Mb
Product: Dell
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: March 17, 2008 at 09:36:46 Pacific
Reply:

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.


0

Response Number 2
Name: keridbey
Date: March 17, 2008 at 10:16:10 Pacific
Reply:

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!


0

Response Number 3
Name: klint
Date: March 17, 2008 at 10:53:14 Pacific
Reply:

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


0

Response Number 4
Name: keridbey
Date: March 17, 2008 at 12:30:56 Pacific
Reply:

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).


0

Response Number 5
Name: klint
Date: March 17, 2008 at 16:26:02 Pacific
Reply:

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.


0

Related Posts

See More



Response Number 6
Name: keridbey
Date: March 18, 2008 at 09:13:59 Pacific
Reply:

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.Quit

Using 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!!!


0

Response Number 7
Name: klint
Date: March 18, 2008 at 10:37:45 Pacific
Reply:

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.


0

Response Number 8
Name: keridbey
Date: March 18, 2008 at 11:54:50 Pacific
Reply:

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!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Verify Proxy.pac

VBA + internet proxy settings www.computing.net/answers/programming/vba-internet-proxy-settings/8020.html

Highly anynomous proxies www.computing.net/answers/programming/highly-anynomous-proxies/7388.html

Programming a proxy in C code www.computing.net/answers/programming/programming-a-proxy-in-c-code/6551.html