Jump to content

change IE proxy settings on the fly


Recommended Posts

My goal is to change Internet explorer proxy on the fly without modifying Registry !

is there a command line tools for that ?

I tried by a wininet.dll call (InternetSetOption) but it is so complexe to implement this call without registry for current IE instance.

please help

Link to comment
Share on other sites

This is quite interesting... There is a whole new world here to explore... I was shocked to see this work...

Dim $oWinmgmts = ObjGet("winmgmts:{impersonationLevel=impersonate}")
Dim $Proxies = $oWinmgmts.InstancesOf("Win32_proxy") 
For $Proxy In $Proxies
    $Proxy.SetProxySetting ("myserver","myport" )
Next

Here are the places I found clues:

in microsoft.public.scripting.wsh

on msdn

Dale

Edit: Added references

My goal is to change Internet explorer proxy on the fly without modifying Registry !

is there a command line tools for that ?

I tried by a wininet.dll call (InternetSetOption) but it is so complexe to implement this call without registry for current IE instance.

please help

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Dim $oWinmgmts = ObjGet("winmgmts:{impersonationLevel=impersonate}")
Dim $Proxies = $oWinmgmts.InstancesOf("Win32_proxy") 
For $Proxy In $Proxies
    $Proxy.SetProxySetting ("myserver","myport" )
Next

Here are the places I found clues:

in microsoft.public.scripting.wsh

on msdn

Dale

Edit: Added references

Thinks for replay but this way make a registry modification and the goal is to to force IE to use a proxy without registry modification.

An other problem is that tis code is not working when IE is loaded (it work only if you reload IE)

Link to comment
Share on other sites

Thinks for replay but this way make a registry modification and the goal is to to force IE to use a proxy without registry modification.

An other problem is that tis code is not working when IE is loaded (it work only if you reload IE)

This was not true for me. I had IE running, ran this code, went to Tools -> Internet Options -> Connections -> Proxy Settings and the value for the proxy server and port showed the new value. I didn't test to see if they were actually being honored however.

If this doesn't work for you, then the only other thing I have ever seen is changing the registry.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

This was not true for me. I had IE running, ran this code, went to Tools -> Internet Options -> Connections -> Proxy Settings and the value for the proxy server and port showed the new value. I didn't test to see if they were actually being honored however.

If this doesn't work for you, then the only other thing I have ever seen is changing the registry.

Dale

here a way without registry and on the fly (for current session only) but with c++ (but my knowledge of c++ is very poor so i can not translate in autoit script)

http://www.codeproject.com/internet/changeproxy1.asp

the autor deals about 3 methods and what i need is the last one

Thinks aagin DaleHohm (I find your IE.au3 very interesting !)

Link to comment
Share on other sites

  • 5 years later...

here a way without registry and on the fly (for current session only) but with c++ (but my knowledge of c++ is very poor so i can not translate in autoit script)

http://www.codeproject.com/internet/changeproxy1.asp

the autor deals about 3 methods and what i need is the last one

Thinks aagin DaleHohm (I find your IE.au3 very interesting !)

Just got below code to refresh proxy settings.

The method is to change proxy setting via regwrite as you like, then call wininet.dll to refresh it

It works fine for me

;INTERNET_OPTION_SETTINGS_CHANGED
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 39, 'ptr', 0, 'dword', 0 )
;INTERNET_OPTION_REFRESH
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 37, 'ptr', 0, 'dword', 0 )
Link to comment
Share on other sites

  • 6 months later...

1) The example I'm giving is just to illustrate the syntax I'm trying to use, suggested in the thread I mentioned. It does not contain the actual values that I'm using when testing it.

2) As I said, this is set in the registry for the ProxyServer registry key in "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings". I don't believe it is passed in the URL.

And here is my question again:

Anyone has any idea how to set up a proxy which needs authentication?

Link to comment
Share on other sites

Unfortunately this does not work for me.

Here is what I'm doing:

#include<IE.au3>
$ProxyKey="HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
#include <ie.au3>
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",0)
RegWrite($ProxyKey,"ProxyServer","REG_SZ","user:pass@xxx.xxx.xxx.xxx:port")
RegWrite($ProxyKey,"ProxyEnable","REG_DWORD","1")
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 39, 'ptr', 0, 'dword', 0 ) ;INTERNET_OPTION_SETTINGS_CHANGED
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 37, 'ptr', 0, 'dword', 0 ) ;INTERNET_OPTION_REFRESH
$oIE2=_IECreate("http://www.whatismyip.com/")
Sleep(10000)
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",1)
RegWrite($ProxyKey,"ProxyServer","REG_SZ","")
RegWrite($ProxyKey,"ProxyEnable","REG_DWORD","0")
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 39, 'ptr', 0, 'dword', 0 ) ;INTERNET_OPTION_SETTINGS_CHANGED
DllCall( 'wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 37, 'ptr', 0, 'dword', 0 ) ;INTERNET_OPTION_REFRESH

The user:pass@xxx.xxx.xxx.xxx:port here is for illustration only. I'm putting real data when testing it, but unfortunately can't share this data here.

I'll appreciate any ideas on how I can make this work.

Link to comment
Share on other sites

Quite hard without a testing environment :D... what about this?

#include<IE.au3>
$sProxy = "xxx.xxx.xxx.xxx:port"
$sUserPass = "user:pass"
$ProxyKey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE", "iexplore.exe", "REG_DWORD", 0)
RegWrite($ProxyKey, "ProxyServer", "REG_SZ", $sProxy)
RegWrite($ProxyKey, "ProxyEnable", "REG_DWORD", "1")
DllCall('wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 39, 'ptr', 0, 'dword', 0) ;INTERNET_OPTION_SETTINGS_CHANGED
DllCall('wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 37, 'ptr', 0, 'dword', 0) ;INTERNET_OPTION_REFRESH
$oIE = _IECreate("http://" & $sUserPass & " @ " & $sProxy)
_IENavigate($oIE, "http://www.whatismyip.com/")
RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE", "iexplore.exe", "REG_DWORD", 1)
RegWrite($ProxyKey, "ProxyServer", "REG_SZ", "")
RegWrite($ProxyKey, "ProxyEnable", "REG_DWORD", "0")
DllCall('wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 39, 'ptr', 0, 'dword', 0) ;INTERNET_OPTION_SETTINGS_CHANGED
DllCall('wininet.dll', 'uint', 'InternetSetOption', 'ptr', 0, 'dword', 37, 'ptr', 0, 'dword', 0) ;INTERNET_OPTION_REFRESH
Edited by KaFu
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...