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.
Best Answer
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:
To set a proxy:
netsh winhttp set proxy [proxy server address:port number] [bypass list]
Example:
netsh winhttp set proxy "myproxy.proxyaddress.com:8484" "<local>;*.proxyaddress.com"
To check your proxy server setting:
To remove the proxy server setting:
The
netsh
command is interactive so you can always just type netsh and then the subsequent commands you need to save some key stroaks.Important note: If you're running on a 64-bit OS, and want the proxy to be applied for 32-bit processes as well, you'll need to also modify your settings by running
C:\Windows\SysWow64\netsh.exe
. This is caused by a bug in Windows 7's version ofnetsh.exe
, which doesn't write the registry values to theWow6432Node
key. This bug seems to be fixed for Windows 10 (and probably Windows 8 as well)