0
votes

I'm currently writing a script in AutoIt to rotate proxies in Internet Explorer that require username/password authentication.

It shouldn't really matter what language I'm writing this in, however, because I am simply making registry writes. I read that I could write proxies that require authentication in the format: "username:password@host:port" to the ProxyServer key. I also tried to add the "http://" prefix and still no luck.

Func _IESetProxy($tProxy)
If $tProxy="0" Then
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 0)
Else
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", "REG_SZ", $tProxy)
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 1)
EndIf
EndFunc

After this code executes and I check internet settings, I notice proxy is enabled, port is correctly 80 but the Address field is blank. When I manually check the registry, the ProxyServer key is filled in correctly with the user:pass@serv:port string I wrote to it.

1

1 Answers

0
votes

Beer's on you.

SetProxy("user:pass@serv,"port")


Func SetProxy($ProxyServer, $ProxyPort = "8080")

    local $ProxyUSER
    local $ProxyPASS

    If StringInStr($proxy,"@") Then

        $proxy1 = StringSplit($proxy, "@")
        $proxy = $proxy1[2]
        $proxy2 = StringSplit($proxy1[1], ":")

        $ProxyUSER = $proxy2[1]
        $ProxyPASS = $proxy2[2]

    EndIf

    $key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

    If $proxy == 0 Then
        $reg = RegWrite($key, "ProxyEnable", "REG_DWORD", "0")
        $reg1 = RegWrite($key, "ProxyServer", "REG_SZ", "")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
        Return 1
    EndIf

    RegWrite($key, "ProxyEnable", "REG_DWORD", "1")
    RegWrite($key, "ProxyServer", "REG_SZ", $ProxyServer & ":" & $ProxyPort)
    RegWrite($key, "ProxyUser", "REG_SZ", $ProxyUSER)
    RegWrite($key, "ProxyPass", "REG_SZ", $ProxyPASS)
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)




EndFunc   ;==>SetProxy