Risposte (5)
Soluzione semplice e funzionante recuperata da http://www.ehow.com/how_6887864_do-proxy-settings-command-prompt_.html
Comando per abilitare l'uso del proxy:
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
Comando per disabilitare l'uso del proxy:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /f
``` &001
Comando per modificare l'indirizzo del proxy:
&001
Ho aggiunto la continuazione della linea (^) per una migliore leggibilità. Inoltre, in questo caso, è più simile ad un'impostazione per utente che ad un'impostazione a livello di sistema.
NetSh al salvataggio!
NetSh winhttp set proxy dovrebbe essere utile. Ecco i comandi:
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"
L'ho fatto in C#, ma la filosofia è la stessa, scrivendo al registro, quindi le seguenti istruzioni possono essere estrapolate al comando da linea. Si devono fare tre cose:
- Scrivere al Registro “HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings”, su ProxyEnable: 1 per abilitare, 0 per disabilitare
- Scrivere al Registro “HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings”, su ProxyServer: xxx.xxx.xxx.xxx.xxx.xxxx:yyyyy (xxx… è l'IP, yy… è la porta)
Dopo aver eseguito i passi 1 e 2 avrete scritto al Registro di sistema l'attivazione del proxy e l'IP e la porta, ma se aprite il browser noterete che non è sufficiente, non potete ancora navigare. Il terzo passo consiste nel modificare il registro di sistema per quanto riguarda le impostazioni delle connessioni:
“Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections” su “DefaultConnectionSettings”.
Si noti che anche se (almeno per W7) ci sono 204 byte in questo registro, è sufficiente modificare solo il byte 8 (9° in quanto il byte 0 è il primo). Il valore del byte 8 non contiene solo informazioni sull'abilitazione/disabilitazione del proxy, ma anche su altre funzionalità:
//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.
Nel mio caso, il ‘Rileva automaticamente le impostazioni’ è sempre abilitato, quindi cambio il valore del byte 8 da 09 a 0B e viceversa per abilitare e disabilitare il proxy.
Creare un file batch e incollare il seguente contenuto (Attiva lo stato 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
Spero di indicarvi la direzione giusta, ma se state cercando di accedere alle impostazioni del proxy attraverso “Opzioni Internet”, aprite semplicemente il menu di avvio e digitate “opzione internet” (qualsiasi impostazione o applicazione potete individuare in questo modo anche l'esempio “proxy”). Dovreste poi riconoscere questo menu ed essere in grado di aggiungere le impostazioni necessarie.