Jump to content

Silly RegWrite/Proxy problem


Recommended Posts

I am trying to create a little script for myself that will change the proxy when I am at work to use the proxy there, or disable it when I get home.

Here is the code:

#include <Inet.au3>
$PublicIP = _GetIP()
If $PublicIP = "XXX.110.170.5" then
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer","REG_SZ","proxy02.XXXX.com:8080")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable","REG_DWORD", 1)
Else
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable","REG_DWORD", 0)
EndIf

For some reason, if the proxy is enabled (1) this code works fine, but if I manually go in and set the ProxyEnable to "0", the script hangs and never completes.

Does this make any sense?

Link to comment
Share on other sites

The current Beta has an updated remarks section for the _GetIP() function:

Remarks

This only returns the Public IP address of a computer or network (i.e. the public IP on the WAN link of your NAT router). The address is determined by accessing an external IP discovery web site like checkip.dyndns.org or www.whatismyip.com.

If you can't reach one of those external IP discovery sites, you have to wait for some long timeouts before you get an error back.

If you are sensing home/work status by the IP on the computer, just use the @IPAddress1 macro instead.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The current Beta has an updated remarks section for the _GetIP() function:

If you can't reach one of those external IP discovery sites, you have to wait for some long timeouts before you get an error back.

If you are sensing home/work status by the IP on the computer, just use the @IPAddress1 macro instead.

:)

Ahh - It makes sense now. Once I disable the Proxy, the GetIP bombs out because it can't reach the external site...

Thanks.

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