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

问题描述 投票:10回答:4

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

internet-explorer proxy
4个回答
4
投票

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

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


3
投票

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 /?

但是这些更改可能不会在Internet Explorer中反映出来。尽管如此,您应该能够在命令行应用程序中使用代理。


1
投票

根据这篇MSDN文章:

Internet Explorer Command Line Options

无法通过命令行更改Internet Explorer代理设置。


0
投票

你也可以通过powershell做到:

<#
.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的参考

© www.soinside.com 2019 - 2024. All rights reserved.