En Windows 7, ¿cómo cambiar la configuración del proxy desde la línea de comandos?

En Windows 7, ¿cómo cambiar la configuración del proxy desde la línea de comandos?

¿Cómo cambio la configuración del proxy desde la línea de comandos en Windows 7?

No me refiero sólo al http_proxy. Necesito establecer la configuración del proxy en todo el sistema (las que están en la configuración de propiedades de Internet). ¿Cómo puedo hacer eso?

Respuesta1

Deberá configurar una secuencia de comandos de registro que realizará los cambios que normalmente haría a través del Panel de control y luego fusionar la secuencia de comandos para habilitar el proxy. También necesitará un script de registro para "deshacer" para deshabilitar los cambios.

En mi caso, tengo dos scripts, enable.reg y enable.reg:

Habilitar 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

Deshabilitar 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

En el script "deshabilitar", =-al final de AutoConfigURL en realidad elimina la clave del registro.

Tenga en cuenta que los valores que ve arriba se modifican a los efectos de esta respuesta. Los valores hexadecimales reales son mucho más largos.

Para usar estos scripts, tenía un archivo por lotes para cada uno, con un aspecto similar a este:

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

Esto es totalmente viable desde la línea de comando.

Respuesta2

Solución simple y funcional recuperada dehttp://www.ehow.com/how_6887864_do-proxy-settings-command-prompt_.html

Comando para habilitar el uso de proxy:

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

Comando para deshabilitar el uso de proxy:

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

Comando para cambiar la dirección del proxy:

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

Agregué una continuación de línea (^) para mejorar la legibilidad. Además, en este caso, se parece más a una configuración por usuario que a una configuración para todo el sistema.

Respuesta3

netsh¡al rescate!

NetSh winhttp set proxy debería ser útil. Aquí están los comandos:

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"

Respuesta4

Cree un archivo por lotes y pegue el siguiente contenido (alternará el estado del Proxy),

@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

información relacionada