.bat 设置网络


设置网络

@echo off
mode con cols=80 lines=10&color 0d
title IP 切换设置

:st
cls
echo.
echo        1.(自动获取家庭无线IP模式) 2.(手动设置公司有线IP模式) 3.(手动设置公司无线IP模式)
echo.
set /p ip=请输入对应数字键后按回车:
echo.
if %ip%==1 goto zd
if %ip%==2 goto sd
if %ip%==3 goto sd2

echo|set /p a=输入错误,请重新输入...&pause>nul&&goto st

:zd
netsh interface ip set address name=无线网络连接 source=dhcp
netsh interface ip set dns name=无线网络连接 source=dhcp
echo 设置完毕...
ping -n 2 127.1>nul
exit

:sd
netsh interface ip set address "本地连接" static 192.168.16.200 255.255.255.0 192.168.16.254
netsh interface ip set DNS   "本地连接" static 218.85.152.99
netsh interface ip add DNS   "本地连接" 218.85.157.99 index=2
if exist %SystemRoot%\setupapi.log del /q %SystemRoot%\setupapi.log
echo 设置完毕...
exit

:sd2
netsh interface ip set address "无线网络连接" static 192.168.16.201 255.255.255.0 192.168.16.254
netsh interface ip set DNS   "无线网络连接" static 218.85.152.99
netsh interface ip add dns   "无线网络连接" 218.85.157.99 index=2
if exist %SystemRoot%\setupapi.log del /q %SystemRoot%\setupapi.log
echo 设置完毕...
exit

:err
echo.
echo 手动设置失败
echo|set /p a=请检查一下IP输写是否正确...

要添加更多的IP,可以接着往下添加

Joyce /
Published under (CC) BY-NC-SA in categories bat  tagged with bat