设置IP和代理的Windows Bat脚本

从什么地方抄来的已经记不清了,为了防止丢失,做个备份。

 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地址为自动获取,然后设置代理服务器为“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地址都是我捏造的,需要根据实际情况填写)。

你可能感兴趣的:(windows)