Jump to content
Sign in to follow this  

Automatic IE proxy switching with username and password

Recommended Posts


I hope someone can help me with this because I did a lot of searching and I've come up with next to nothing..

I'm trying to automatically switch IE proxies using a list of known proxies all of which have the same username and password. Here's the code I'm using to switch proxies:

Func SetProxySetting($myProxyServer, $myProxyPort)
    $winmgmts = ObjGet("winmgmts:{impersonationLevel=impersonate}")
    $win32_Proxy = $winmgmts.InstancesOf ("win32_Proxy")
    Dim $Array[1]
    For $Obj In $win32_Proxy
        $result = $Obj.SetProxySetting($myProxyServer,$myProxyPort)
        $Array[UBound($Array) - 1] = $result
        ReDim $Array[UBound($Array) + 1]
    ReDim $Array[UBound($Array) - 1]
    Return $Array

I take no credit for that, I got it from another thread on this forum. It works great for switching proxies but doesn't allow you to specify a user/pass. I've taken a look at the docs for winmgmts and win32_proxy too and they don't seem to say anything about user/pass. So I thought I'd just open a hidden IE window and send the login credentials through the url like... http://user:pass@somesite.com

It would be dirty but it would get the job done, except it doesn't. Apparently as of IE 7 Microsoft has deemed passing login info in the url as a ;834489"]security risk and doesn't let you do it unless you set a registry key for each user. Too messy.

I've also tried to find any registry key responsible for holding the login credentials, I couldn't find one.

Is there any other way of authenticating a proxy that's already been set?

Share this post

Link to post
Share on other sites

Okay I might have found something. I might be able to use this InternetSetOption function to set the user/pass using the "INTERNET_OPTION_PROXY_USERNAME" and "INTERNET_OPTION_PROXY_PASSWORD" option flags. I've never done anything in AutoIt with DLLs though so I need some help.

So far all I have is..

DllCall('wininet.dll', 'BOOLEAN', 'InternetSetOption'
I'm not sure how to pass the parameters since the first one is some weird type. Could someone help me?

Actually I'm not even sure if this will work because.. even if it does work will it authenticate future IE sessions? I might just have to try it out to see.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this