2012-05-02 16:08:50 +0000 2012-05-02 16:08:50 +0000
46
46
Advertisement

在Windows7中,如何从命令行更改代理设置?

Advertisement

在Windows 7中,如何从命令行更改代理设置?

我说的不仅仅是http_proxy。我需要设置全系统的代理设置(Internet属性设置中的代理设置)。我该怎么做呢?

Advertisement
Advertisement

答案 (5)

62
62
62
2012-08-29 10:57:56 +0000

简单而有效的解决方案来自于http://www.ehow.com/how (http://www.ehow.com/how6887864/do-proxy-settings-command-proxy-settings-command-prompt.html

启用代理使用命令:

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

禁止代理使用命令:

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

更改代理地址的命令:

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

我在这里加了行的延续(^),以提高可读性。另外,在这种情况下,它更像是每个用户的设置,而不是全系统的设置。

27
27
27
2012-05-02 19:56:20 +0000

NetSh](http://technet.microsoft.com/en-us/library/cc731131%28WS.10%29.aspx#BKMK_5)来救命!

NetSh winhttp set proxy应该会有帮助。下面是命令:

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"

&007

4
Advertisement
4
4
2015-12-05 10:02:58 +0000
Advertisement

我是用C#做的,但幽幽也是一样的,写到注册表,所以可以推导出下面的指令,写到行命令。应做三件事:

  1. 写到注册表 “HKCUSoftware\Microsoft\Windows\CurrentVersion\Internet Settings",在ProxyEnable上。1为启用,0为禁用

  2. 寫到註冊處 "HKCUSoftwareMicrosoftWindowsCurrentVersion\Internet Settings”, 在ProxyServer上: xxx.xxx.xxx.xxx.xxx:yyyyyy (xxx…是IP, yy….是端口)

  3. 在执行完步骤1和2后,你会把代理的激活和IP和端口写到注册表上,但如果你打开浏览器,你会发现还不够,还不能导航。第三步是修改注册表中关于连接设置的内容:

“Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections "上的 "DefaultConnectionSettings"。字节8的值不仅包含了关于代理启用/禁用的信息,还包含了其他功能的信息:

//09 when only 'Automatically detect settings' is enabled 
        //03 when only 'Use a proxy server for your LAN' is enabled
        //0B when both are enabled
        //05 when only 'Use automatic configuration script' is enabled
        //0D when 'Automatically detect settings' and 'Use automatic configuration script' are enabled
        //07 when 'Use a proxy server for your LAN' and 'Use automatic configuration script' are enabled
        //0F when all the three are enabled. 
        //01 when none of them are enabled.

在我的例子中,"自动检测设置 "总是启用的,所以我把字节8的值从09切换到0B,然后再切换到0B,这样就可以启用和禁用代理。

2
2
2
2012-09-14 13:27:28 +0000

创建一个批处理文件并粘贴以下内容(会切换代理状态),

@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
-3
Advertisement
-3
-3
2012-05-02 16:18:31 +0000
Advertisement

我希望我在这里指点你的方向是正确的, 但如果你想通过 “互联网选项 "访问代理设置, 只需打开开始菜单并输入 "互联网选项”(任何设置或应用程序,你可以通过这种方式找到的任何设置或应用程序也可以例如 “代理”). 这时你应该能认出这个菜单,并能添加你需要的设置。

Advertisement

相关问题

3
19
10
28
6
Advertisement
Advertisement