【问题标题】:Batch / BAT - Change proxy settings with a batch / BAT file批处理/BAT - 使用批处理/BAT 文件更改代理设置
【发布时间】:2010-12-27 20:15:48
【问题描述】:

有人可以教我如何使用 .bat 文件或建议更改代理设置吗? 老实说,我找不到很好的信息。

我需要一个 .bat 文件,该文件将使用特定的代理 ip 和端口更改我的互联网设置(代理)。

谢谢

【问题讨论】:

    标签: proxy batch-file settings


    【解决方案1】:

    Internet Explorer 的代理服务器设置存储在Software\Microsoft\Windows\CurrentVersion\Internet Settings 下的注册表中。

    使用Powershell(自 Windows 7 起包含在 Windows 中),您可以使用:

    set-itemproperty -path "hkcu:Software\Microsoft\Windows\CurrentVersion\Internet Settings" -name ProxyServer -value "http=proxy-url:port;https=proxy-url:port;ftp=proxy-url:port;socks=proxy-url:port;" -type string

    此设置只会影响 Internet Explorer,并且可能需要一个新选项卡,甚至可能需要重新启动 IE,尽管这不太可能。

    【讨论】:

    • Set-ItemProperty :缺少参数“名称”的参数。指定“System.String”类型的参数,然后重试。在 line:1 char:91 + ... rnet Settings" -name + ~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-ItemProperty], ParameterBindingException + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.SetItemPropertyCommand
    【解决方案2】:

    如果您不想安装 Powershell,另一种选择是使用命令 REG.exe

    因此,在这种情况下,您应该在批处理脚本中添加:

    REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "http=proxy-url:port;https=proxy-url:port;ftp=proxy-url:port;socks=proxy-url:port;" /t REG_SZ /f

    有关信息,Google Chrome 也使用代理 Internet Explorer 设置

    【讨论】:

    • 在win32上Chrome/Chromium会使用IE代理设置(即系统设置)unless你在命令行指定代理,例如chrome.exe" --proxy-server="socks5://localhost:9090"或-proxy-server=127.0.0.1:8080
    • 如何为私有代理添加用户名和密码?
    • 让我补充一点,与大多数注册表设置不同,这个设置可以毫不拖延地工作。您双击您的批处理脚本,它会立即应用。如果您还想启用代理,请添加以下行:REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /d 1 /t REG_DWORD /f
    猜你喜欢
    • 2010-09-14
    • 2022-01-05
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    相关资源
    最近更新 更多