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.

How do I change proxy settings from command line in Windows 7?

I'm not talking about just the http_proxy. I need to set system-wide proxy settings (the ones in Internet properties setting). How do I do that?

share|improve this question
add comment

5 Answers

up vote 3 down vote accepted

You'll need to configure a registry script that will make the changes you normally would via the Control Panel, and then merge the script to enable the proxy. You would also need an "undo" registry script to disable the changes.

In my case, I have two scripts, enable.reg and disable.reg:

Enable Proxy:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"AutoConfigURL"="http://10.10.10.1/autoproxy/proxy.pac"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]
"DefaultConnectionSettings"=hex:16,00,00,00,05,02,00,00,0d,00,00,00,0e,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"SavedLegacySettings"=hex:36,00,00,00,46,1a,00,00,0d,00,00,00,0e,00,00,00,32,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

Disable Proxy:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"AutoConfigURL"=-

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]
"DefaultConnectionSettings"=hex:16,00,00,00,05,02,00,00,0d,00,00,00,0e,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"SavedLegacySettings"=hex:36,00,00,00,46,1a,00,00,0d,00,00,00,0e,00,00,00,32,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

In the "disable" script, the =- at the end of AutoConfigURL actually deletes the key from the registry.

Note that the values you see above are modified for the purposes of this answer. The actual hex values are much longer.

To use these scripts, I had a batch file for each one, looking something like this:

@echo off
start /min reg import C:\Path\To\Registry\File\enable_proxy.reg

That is fully workable from the command line.

share|improve this answer
    
I ended up doing something like this. I didn't know how to manipulate registry from batch script so I wrote c# code for this.. :). thanx anyways.. –  prongs May 3 '12 at 10:41
add comment

Simple and working solution retrieved from http://www.ehow.com/how_6887864_do-proxy-settings-command-prompt_.html

Command to enable proxy usage:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 1 /f

Command to disable proxy usage:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 0 /f

Command to change the proxy address:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /f

I have added line continuation (^) for improved readability. Also, in this case, it is more like a per-user setting than a system-wide setting.

share|improve this answer
    
IMO, this is the actual answer to the question. Thanks @sayap –  kmonsoor Dec 26 '12 at 4:21
1  
+1. This is a much more elegant solution to mine. –  user3463 Jul 29 '13 at 20:28
    
Note: The ^ characters are not part of the commands. –  Joshua Drake Oct 10 '13 at 19:40
add comment

NetSh to the rescue!

NetSh winhttp set proxy should be helpful. Here are the commands:

netsh winhttp set proxy myproxy

netsh winhttp set proxy myproxy:80 "<local>bar"

netsh winhttp set proxy proxy-server="http=myproxy;https=sproxy:88" bypass-list="*.contoso.com"

share|improve this answer
    
Clearing the proxy using netsh: netsh winhttp reset proxy –  Kevin Driedger Aug 15 '12 at 19:15
2  
I think this only applies to application that uses the WinHTTP library. After a quick test, it doesn't seem like any common application on my system uses that. –  sayap Aug 29 '12 at 11:01
add comment

Create a batch file and paste following content(It will toggle the Proxy state),

@echo off

FOR /F "tokens=2* delims=    " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable') DO SET currentProxy=%%B
rem ECHO currentProxy=%currentProxy%

if %currentProxy%==0x1 (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
echo Proxy Disabled
) else (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
echo Proxy Enabled
  )

pause
share|improve this answer
    
This is very similar to @sayap's answer. –  user3463 Jul 29 '13 at 20:29
add comment

I hope I am pointing you in the correct direction here, but if you are trying to access the proxy settings through "Internet options", simply open the start menu and type "internet option" (any setting or application you can locate this way also example "proxy"). You should then recognize this menu and be able to add your needed settings.

share|improve this answer
    
dude... you didn't see the title proprely... I know what you are trying to tell me. I want to do it from command line. –  prongs May 2 '12 at 16:24
    
sorry man, seems like buddy got you all fixed up though –  Luke Russell May 2 '12 at 17:41
add comment

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.