Jump to content

Recommended Posts

Posted

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

Posted (edited)

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

Posted

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)

Posted

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

Posted

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

  • 5 years later...
Posted

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 )
  • 6 months later...
Posted

Hi.

1.) the example you are giving is addressing a localhost proxy. You propably want to use the proxy on a different (server) host?

2.)See this M$ KB article: "IE does not support user:pass@host:port in URLs:"

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted

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?

Posted

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.

Posted (edited)

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
Posted

is this working?

HttpSetProxy(2, "proxy:port", "username", "password")

ConsoleWrite(BinaryToString(InetRead("http://www.google.com")))

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
  • Recently Browsing   0 members

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