新闻动态

BAT脚本实现自动IP地址切换 

发布日期:2022-07-15 19:18 | 文章来源:源码中国

BAT自动IP地址切换脚本如下:

@echo off
color 3f
mode con cols=80 lines=30
title 自动IP地址切换脚本 By 小强
if "%1"=="1" goto office
if "%1"=="2" goto Home
if "%1"=="3" goto dhcp
:start
cls
echo=
echo ============================================================================
echo=
echo 1.切换到办公室IP
echo=
echo 2.切换到家里的IP
echo=
echo 3.切换到自动获取
echo=
echo 0.退·出·脚·本
echo=
echo ============================================================================
echo=
set choice=
set /p choice=请输入你的选择:
if "%choice%"=="1" goto office
if "%choice%"=="2" goto Home
if "%choice%"=="3" goto dhcp
if "%choice%"=="0" exit
echo 输入有误,请重新选择!
pause>nul
goto start
 
:office
cls
cls
echo.
echo 正在设置IP为办公IP请等待...
echo.
set net_interface="本地连接"
echo 设置IP中...
netsh interface ip set address "%net_interface%" source=static addr=192.168.0.5 mask=255.255.255.0
echo 设置IP成功...设置网关中...
netsh interface ip set address name="%net_interface%" gateway=192.168.0.1 gwmetric=1
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" static 202.98.0.68
netsh interface ip add dns "%net_interface%" 202.98.5.68 index=2
echo IP已成功切换到办公设置,任意键返回...
pause>nul
goto start
 
:home
cls
echo.
echo 正在设置为家用IP请等待...
echo.
set net_interface="本地连接"
echo 设置IP中...
netsh interface ip set address "%net_interface%" source=static addr=192.168.1.111 mask=255.255.255.0
echo 设置IP成功...设置网关中...
netsh interface ip set address name="%net_interface%" gateway=192.168.1.1 gwmetric=1
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" static 218.85.152.99
netsh interface ip add dns "%net_interface%" 218.85.157.99 index=2
echo IP已成功切换到办公设置,任意键返回...
pause>nul
goto start
 
:DHCP
echo.
echo 正在设置IP为自动获取,请等待...
echo.
set net_interface="本地连接"
echo 设置IP中...
netsh interface ip set address name="%net_interface%" source=dhcp
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" source=dhcp
echo 设置成功!按任意键返回选择菜单。
pause>nul
GOTO start

到此这篇关于BAT脚本实现自动IP地址切换 的文章就介绍到这了,更多相关BAT IP地址切换 内容请搜索本站以前的文章或继续浏览下面的相关文章希望大家以后多多支持本站!

香港服务器租用

版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。

相关文章

实时开通

自选配置、实时开通

免备案

全球线路精选!

全天候客户服务

7x24全年不间断在线

专属顾问服务

1对1客户咨询顾问

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部