平时往返于公司、宿舍和客户地点办公,网络的频繁切换虽然不会影响到工作的效率,但拥有一个网络切换工具会方便很多,心情也会得到愉悦。
@echo off
rem 用户提权,以管理员身份运行
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
rem 修改背景和字体颜色
rem 下面是对应关系:
rem 0=黑、1=蓝、2=绿、3=浅绿、4=红、5=紫、6=黄、7=白、8=灰、9=淡蓝
rem A=淡绿、B=淡浅绿、C=淡红、D=淡紫、E=淡黄、F=亮白
color 8F
rem 功能初始化
echo ---------------------------------------------------------------------------------------------
echo ^| 根据服务菜单,输入对应的数字 ^|
echo =============================================================================================
echo ^| ^| ^| ^|
echo ^| 1.宿舍无线网络设置 ^| 2.以太网 2网络设置 ^| 3.无线网DHCP ^| 4.以太网 2 DHCP ^|
echo ^| ^| ^| ^|
echo ---------------------------------------------------------------------------------------------
goto :initial
rem 用户输入
:initial
set/p selecter=输入对应的数字:
call :handleSwitch %selecter%
:handleSwitch
if %1==1 (
call :hourseInNanJing
) else if %1==2 (
call :localNetWork2
) else if %1==3 (
call :WLANDHCP
) else if %1==4 (
call :DHCPLocal2
) else (
echo 选项不正确
)
goto initial
rem 南京宿舍
:hourseInNanJing
netsh interface ip set address "WLAN" static 172.16.10.80 255.255.255.0 172.16.10.254
netsh interface ip set dns "WLAN" static 114.114.114.114
goto initial
rem 以太网 2
:localNetWork2
netsh interface ip set address "以太网 2" static 172.16.10.118 255.255.255.0 172.16.10.254
netsh interface ip set dns "以太网 2" static 172.16.10.12
goto initial
rem WLAN DHCP 动态设置
:WLANDHCP
netsh interface ip set address "WLAN" dhcp
netsh interface ip set dns "WLAN" dhcp
goto initial
rem 以太网 2 DHCP 动态设置
:DHCPLocal2
netsh interface ip set address "以太网 2" dhcp
netsh interface ip set dns "以太网 2" dhcp
goto initial