开发者

is it possible to change IE proxy settings from command line

I am looking for options which will allow me change connection proxy i开发者_StackOverflow中文版nformation of IE thru command line.


IE proxy settings are controlled via registry keys. In general you should change them manually since this implementation detail can change between versions. However, as a debugging tool its useful.

Anyway, you can change registry keys from the command line using the REG command. Specifically, I would just create some .reg files with the various states you want to change to and do REG IMPORT example-file.reg. Or, failing that, REG ADD.


proxycfg might be the tool you are looking for.

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)

It works well in windows XP
In next windows versions, you can use:

C:\>netsh winhttp import proxy source=ie

to import proxy settings from Internet Explorer and

C:\>netsh winhttp reset proxy

to reset proxy settings for more help, use:

C:\>netsh winhttp /?

But these changes might not get reflected in Internet Explorer. Nonetheless, you should be able to use proxy in command line applications.


you could also make it via 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"
        }
    }
}

you could find the reference here Set-InternetProxy : Enable proxy with PowerShell


According to this MSDN article:

Internet Explorer Command Line Options

there is no way to change Internet Explorer's proxy settings via the command line.


this is a question that is almost 11 years old but...

if there are some windows 10 users that need this done on cmd

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v proxyEnable /t REG_DWORD /d 1 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v proxyServer /t REG_SZ /d socks=localhost:4444 /f

if you check the checkbox the work is done.

is it possible to change IE proxy settings from command line


you could also use netsh:

// for a Socks proxy

netsh winhttp set proxy proxy-server="socks=10.0.0.254:1080" bypass-list="localhost"


// using credentials

netsh winhttp set proxy proxy-server="http=aUser:aPass@10.0.0.254;aUser:aPass@https=10.0.0.254;" bypass-list="localhost"


// reset proxy

netsh winhttp reset proxy 


0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜