window下ip切换

切到静态地址

@echo off
echo  ***********************************
echo  *          modify to static ip    *
echo  ***********************************
echo  start change ip addr .....

netsh interface ipv4 set address name="无线网络连接" source=static addr=192.168.2.111 mask=255.255.255.0 gateway=192.168.2.1 gwmetric=0

echo start change dns ....

netsh interface ipv4 set dns name="无线网络连接" source=static addr=114.114.114.114 register=PRIMARY

pause

切到动态地址

@echo off
echo  ***********************************
echo  *          modify to dhcp ip      *
echo  ***********************************
echo  start change ip addr .....

netsh interface ipv4 set address name="无线网络连接" source=dhcp

echo start change dns ....

netsh interface ipv4 set dns name="无线网络连接" source=dhcp

pause

  • 注意:批处理文本存储时一定要是gbk(gb2312)编码,不然会出现问题
posted @ 2017-04-25 14:14  zyh_think  阅读(230)  评论(0编辑  收藏  举报