從什麼地方抄來的已經記不清了,為了防止丟失,做個備份。
1 @echo off
2 cls
3 color 0A
4 Echo The program is running...
5 Echo Setting the ip and dns...
6 netsh interface ip set address name="Local Connection" source=dhcp
7 netsh interface ip delete dns "Local Connection" all
8 ipconfig /flushdns
9 ipconfig /all
10 Echo Done.
11 Echo Setting the proxy
12 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
13 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "proxy:80" /f
14 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "" /f
15 ipconfig /flushdns
16 Echo Done.
17 Echo Press any key to leave...
18 Pause
這段代碼第一部分設定ip地址為自動擷取,然後設定Proxy 伺服器為“porxy:80”;
1 @echo off
2 cls
3 Echo The program is running...
4 Echo Setting the ip and dns...
5 cmd /c netsh interface ip set address name="Local Connection" source=static addr=192.168.2.12 mask=255.255.255.0 gateway=192.168.2.1 gwmetric=1
6 cmd /c netsh interface ip set dns name="Local Connection" source=static addr=192.168.2.254 primary
7 cmd /c netsh interface ip add dns name="Local Connection" addr=192.168.2.253 index=2
8 ipconfig /all
9 Echo Done
10
11 Echo Setting the proxy...
12 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
13 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
14 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d 0 /f
15 Echo Done.
16 Pause
這段代碼設定了固定的IP地址和DNS等配置資訊,同時刪除了代理設定資訊(文中的IP地址都是我捏造的,需要根據實際情況填寫)。