首页 > 编程知识 正文

BAT一键切换Windows IP地址,电脑怎么一键切换

时间:2023-05-03 10:03:29 阅读:269859 作者:3270

参考文章:

https://www.jb51.net/article/48078.htm

修改说明:

我在原来代码的基础上修正了一些,包括

@netsh int ipv4 set address "以太网" static 192.168.1.27 255.255.254.0 192.168.1.254 1 >nul

我把ip改成了ipv4,还有address后面的“以太网”是要根据自己电脑实际情况来修改的

最后我加了一个pause,这样bat窗口不会立马关掉

@echo offrem # ----------------------------------rem # 接口 IP 配置 rem # ----------------------------------echo "=========IP 控制管理=========="echo "=> d: 自动获取IP"echo "=> e: ENI IP地址:10.7.205.222"echo "=> l: 实验室 IP地址:192.168.1.27"echo "请输入对应的序号d,e,l,按回车键结束: "set /p ch=if %ch%=="" echo "You input null"&goto :EOFset case=d,e,l>nulecho %case%|findstr "<%ch%>">nul&if errorlevel 1 goto :errgoto %ch%goto err:e:: "ENI"echo "configure home ip address gateway,please wait 30 second ..."@netsh int ipv4 set address "以太网" static 10.7.205.222 255.255.255.0 10.5.22.66 1 >nul@netsh int ipv4 set dns "以太网" static 10.5.22.66 PRIMARY >nulecho home ip configure is doneecho "完成!回车退出!"pausegoto :EOF:l:: "实验室"echo "configure transport ip address gateway,please wait 30 second ..."@netsh int ipv4 set address "以太网" static 192.168.1.27 255.255.254.0 192.168.1.254 1 >nul@netsh int ipv4 set dns "以太网" static 202.96.209.5 PRIMARY >nulecho transport ip configure is doneecho "完成!回车退出!"pausegoto :EOF:d:DHCP "自动获取IP地址"echo "configure transport ip address gateway,please wait 30 second ..."@netsh int ipv4 set address "以太网" dhcp >nul@netsh int ipv4 set dns "以太网" dhcp >nulecho "完成!回车退出!"pausegoto :EOF:err:: "error"echo your input "%ch%" ,no this argument ! check your input! game overrem # 接口 IP 配置结束极速赛车稳赚4码配置结束

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。