@echo off
cls
echo.
rem 新區(qū)ip配置
rem ip //設置IP地址
set ip1=10.13.40.60
rem gw //設置網(wǎng)關
set gw1=10.13.40.1
rem netmasks //設置子網(wǎng)掩碼
set netmasks1=255.255.254.0
rem 老區(qū)ip配置
rem ip //設置IP地址
set ip2=192.168.1.123
rem gw //設置網(wǎng)關
set gw2=192.168.1.1
rem netmasks //設置子網(wǎng)掩碼
set netmasks2=255.255.255.0
rem 宿舍ip配置
rem ip //設置IP地址
set ip3=192.168.1.123
rem gw //設置網(wǎng)關
set gw3=192.168.1.1
rem netmasks //設置子網(wǎng)掩碼
set netmasks3=255.255.255.0
rem dns1 //設置主DNS
set dns1=61.147.37.1
rem dns2 //設置輔DNS
set dns2=61.177.7.1
set eth=本地連接
:MENU
echo.
echo 新區(qū)設置請按-1
echo.
echo 老區(qū)設置請按-2
echo.
echo 宿舍默認請按-3
echo.
echo 自動獲取請按-4
echo.
echo 察看狀態(tài)請按-5
echo.
echo.
set /p KEY= 請輸入您的選擇:
if %KEY% == 1 goto 新區(qū)
if %KEY% == 2 goto 老區(qū)
if %KEY% == 3 goto 宿舍
if %KEY% == 4 goto DHCP
if %KEY% == 5 goto LOOK
goto END
:LOOK
echo.
ipconfig
echo.
echo 本程序默認修改的是“本地連接”的設置
echo.
echo 需要修改請按相應的數(shù)字鍵,
echo.
echo 例如:輸入2表示改為“本地連接 2”
echo.
set /p INTEMP= [請輸入本地連接的編號]
if %INTEMP% == 1 set eth=本地連接
if %INTEMP% == 2 set eth=本地連接 2
if %INTEMP% == 3 set eth=本地連接 3
if %INTEMP% == 4 set eth=本地連接 4
if %INTEMP% == 5 set eth=本地連接 5
cls
goto MENU
:新區(qū)
echo 正在將本機IP更改到:%ip1%
netsh interface ipv4 set address "%eth%" static %ip1% %netmasks1% %gw1%
echo 正在添加本機主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本機副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完畢,檢查當前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:老區(qū)
@echo off
echo 正在將本機IP更改到:%ip2%
netsh interface ipv4 set address "%eth%" static %ip2% %netmasks2% %gw2%
echo 正在添加本機主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本機副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完畢,檢查當前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:宿舍
@echo off
echo 正在將本機IP更改到:%ip3%
netsh interface ipv4 set address "%eth%" static %ip3% %netmasks3% %gw3%
echo 正在添加本機主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本機副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完畢,檢查當前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:DHCP
echo 正在將本機IP更改為自動獲取:
netsh interface ipv4 set address "%eth%" dhcp
echo 正在添加本機主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1% primary
echo 正在添加本機副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo IP更改完畢,檢查當前配置...
echo ------------------------------
ipconfig /all
pause
goto end
:end
pause