代码之家  ›  专栏  ›  技术社区  ›  balalakshmi

可以从命令行更改IE代理设置吗

  •  10
  • balalakshmi  · 技术社区  · 16 年前

    我正在寻找允许我通过命令行更改IE连接代理信息的选项。

    4 回复  |  直到 7 年前
        1
  •  4
  •   i_am_jorf    16 年前

    IE代理设置通过注册表项控制。一般来说,您应该手动更改它们,因为此实现细节可以在版本之间更改。但是,作为一个调试工具,它很有用。

    无论如何,您可以使用命令行更改注册表项。 REG 命令。具体来说,我只创建一些.reg文件,其中包含您要更改为的各种状态和要执行的操作。 REG IMPORT example-file.reg .或者,如果失败, REG ADD .

        2
  •  3
  •   Srichakradhar    12 年前

    proxycfg可能是您正在寻找的工具。

    C:\>proxycfg /?
    Microsoft (R) WinHTTP Default Proxy Configuration Tool
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    usage:
    
        proxycfg -?  : to view help information
    
        proxycfg     : to view current WinHTTP proxy settings
    
        proxycfg [-d] [-p <server-name> [<bypass-list>]]
    
            -d : set direct access
            -p : set proxy server(s), and optional bypass list
    
        proxycfg -u  : import proxy settings from current user's
                       Microsoft Internet Explorer manual settings (in HKCU)
    

    它在Windows XP中运行良好
    在下一个Windows版本中,您可以使用:

    C:\>netsh winhttp import proxy source=ie
    

    从Internet Explorer导入代理设置 和

    C:\>netsh winhttp reset proxy
    

    重置代理设置

    C:\>netsh winhttp /?
    

        4
  •  0
  •   Kevin Xiong    7 年前

    <#
    .Synopsis
    This function will set the proxy settings provided as input to the cmdlet.
    .Description
    This function will set the proxy server and (optinal) Automatic configuration script.
    .Parameter ProxyServer
    This parameter is set as the proxy for the system.
    Data from. This parameter is Mandatory
    .Example
    Setting proxy information
    Set-InternetProxy -proxy "proxy:7890"
    .Example
    Setting proxy information and (optinal) Automatic Configuration Script 
    Set-InternetProxy -proxy "proxy:7890" -acs "http://proxy:7892"
    #>
    
    Function Set-InternetProxy {
        [CmdletBinding()]
        Param(      
            [Parameter(Mandatory = $True, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
            [String[]]$Proxy,
    
            [Parameter(Mandatory = $False, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
            [AllowEmptyString()]
            [String[]]$acs               
        )
    
        Begin {
            $regKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"      
        }   
        Process {
            Set-ItemProperty -path $regKey ProxyEnable -value 1
            Set-ItemProperty -path $regKey ProxyOverride -Value "<local>"
            Set-ItemProperty -path $regKey ProxyServer -value $proxy                        
            if ($acs) {                    
                Set-ItemProperty -path $regKey AutoConfigURL -Value $acs          
            }
        }    
        End {
            Write-Output "Proxy is now enabled"
            Write-Output "Proxy Server : $proxy"
            if ($acs) {       
                Write-Output "Automatic Configuration Script : $acs"
            }
            else {           
                Write-Output "Automatic Configuration Script : Not Defined"
            }
        }
    }
    
    

    Set-InternetProxy : Enable proxy with PowerShell