其他分享
首页 > 其他分享> > bat脚本实现一键IP切换

bat脚本实现一键IP切换

作者:互联网

%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
@echo off
color 2
title    设置上网环境
echo                            *******请选择上网环境******
echo                            固定IP模式=========》按1键
echo                            自动获取模式=======》按2键
echo                            固定IP10模式=======》按3键
set/p n=
if /i "%n%" equ "1" goto guding
if /i "%n%" equ "2" goto zidong
if /i "%n%" equ "3" goto guding2

: guding
echo 您选择了固定IP模式
echo 正在设置Ip 192.168.10.10,请稍后......
netsh interface ipv4 set address "local" static  192.168.10.10 255.255.255.0 192.168.0.1
netsh interface ip  set  address "local" static  192.168.10.10 255.255.255.0 192.168.0.1
goto end

: zidong
echo 您选择了家用自动获取模式
echo 正在设置,请稍后......
echo 自动获取IP地址....
@echo off
netsh interface ip set address name = "local" source = dhcp
echo 自动获取DNS服务器....
netsh interface ip set dns name = "local" source = dhcp
goto end

: guding2
echo 您选择了固定IP模式
echo 正在设置Ip 10.0.0.10,请稍后......
netsh interface ipv4 set address "local" static  10.0.0.10 255.255.255.0 10.0.0.1
netsh interface ip  set  address "local" static  10.0.0.10 255.255.255.0 10.0.0.1
goto end

 :end

color 6
echo ********本机当前IP配置如下********
ipconfig /all
echo ********设置成功!感谢使用*********
pause

标签:bat,set,netsh,IP,一键,echo,interface,local,goto
来源: https://blog.csdn.net/qq_38082979/article/details/122665668