Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Windows 7, Is it possible to define/change the proxy config from the command line?

So, using the GUI, I would go:

Start → Control Panel → Network and Internet → Internet Options → Connections → LAN Settings

and then

  • enable/disable the proxy;
  • define IP:port of proxy server.

But I would like to rather do this from the command line (so that I can run the command from a batch-file with a shortcut key — enabling me to switch proxy configs using a short-cut, rather than having to wade through the MS wizard).

I've looked at using netsh.exe to change the settings for WinHTTP, but this seems to be thr wrong thing to do, as the WinHTTP setting do not appear to be related to the LAN settings.

share|improve this question

migrated from serverfault.com Sep 20 '11 at 7:29

This question came from our site for professional system and network administrators.

4 Answers 4

up vote 4 down vote accepted

In Windows 7 proxycfg.exe has been replaced with the netsh command. Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. To setup a local machine proxy you would use the following syntax:

  • open a command prompt in administrative mode (hit start globe, type cmd, then hit Ctrl+Shift + Enter)

To set a proxy:

netsh winhttp set proxy [proxy server address:port number] [bypass list]

Example:

netsh winhhtp set proxy "myproxy.proxyaddress.com:8484" "<local>;*.proxyaddress.com"

To check your proxy server setting:

netsh winhttp show proxy

To remove the proxy server setting:

netsh winhttp reset proxy

The netsh command is interactive so you can always just type netsh and then the subsequent commands you need to save some key stroaks.

share|improve this answer
    
For Windows 7 :Usage: set proxy [proxy-server=]<server name> [bypass-list=]<hosts list> Parameters: Tag Value proxy-server - proxy server for use for http and/or https protocol bypass-list - a list of sites that should be visited bypassing the proxy (use "<local>" to bypass all short name hosts) Examples: set proxy myproxy set proxy myproxy:80 "<local>;bar" set proxy proxy-server="http=myproxy;https=sproxy:88" bypass-list="*.foo.com" –  Gerrie Mar 4 at 6:42

and yet it appears to be the correct way: technet

I use proxycfg for 2003/xp, funny to see it has changed, I didn't know. Oh well.

share|improve this answer
2  
Unfortunately, netsh>winhttp is NOT the answer. By way of justification, changes to the LAN proxy setting made through the GUI are NOT reflected by netsh>winhttp>show proxy, and vice versa. –  david.barkhuizen Oct 11 '10 at 8:43

I do not know how to change proxy in windows 7 from command line.

But there is a tool to switch Windows proxies easily. We can configure several proxies and switch between proxies from the system tray. I know this is not the answer you are looking for but will probably help other users.

Check here:

http://www.winhelponline.com/blog/quickly-switch-proxy-settings-using-ieproxy/

http://ieproxy.codeplex.com/releases/view/19014

EDIT:

Btw, these are the registry settings for Windows proxy, should be easy to write a script to change the ie proxy from command line. I haven't tried it though.

http://ozansafi.wordpress.com/2009/07/05/enabledisable-change-ie-proxy-by-scriptprogrammatically/

share|improve this answer

I have the following code tested on Windows XP. You can give it a try on Windows 7.

Remember to replace x.x.x.x:p with the IP address and port of your proxy server.

To set up,

setlocal
set SUBKEY=Software\Microsoft\Windows\CurrentVersion\Internet Settings
reg add "HKCU\%SUBKEY%" /f /v MigrateProxy /t REG_DWORD /d 0x1
reg add "HKCU\%SUBKEY%" /f /v ProxyEnable /t REG_DWORD /d 0x1
reg add "HKCU\%SUBKEY%" /f /v ProxyServer /t REG_SZ /d "x.x.x.x:p"
reg add "HKCU\%SUBKEY%" /f /v ProxyOverride /t REG_SZ /d "<local>"
endlocal

To remove (also settings for dialup connections),

setlocal
set SUBKEY=Software\Microsoft\Windows\CurrentVersion\Internet Settings
reg delete "HKCU\%SUBKEY%\Connections" /f
reg add    "HKCU\%SUBKEY%" /f /v MigrateProxy /t REG_DWORD /d 0x1
reg add    "HKCU\%SUBKEY%" /f /v ProxyEnable /t REG_DWORD /d 0x0
reg delete "HKCU\%SUBKEY%" /f /v ProxyServer
reg delete "HKCU\%SUBKEY%" /f /v ProxyOverride
endlocal
share|improve this answer
    
But then, it seems you need to open up the LAN Settings window and close it for it to take effect... –  Dov Feb 16 '12 at 13:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.