设置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地址都是我捏造的,需要根据实际情况填写)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值