勇敢追求自己,加油加油
分类: WINDOWS
2010-10-22 23:26:02
@echo off
title IP_Config
cls
color 3E
echo.
echo File:IP_Config
echo.
echo Script By:
echo.
echo Script Version:20091105
echo.
echo.
echo IP地址配置开始……
set NAME="本地连接"
set IP1=10.0.50.22
set MASK1=255.255.255.0
set GATEWAY1=10.0.50.1
set IP2=192.168.1.101
set MASK2=255.255.255.0
set GATEWAY2=192.168.1.1
set dns1="202.96.209.133"
set dns2="202.96.209.6"
set dns3="203.95.1.1"
set dns4="203.95.1.2"
:START
set KEY=-1
echo.
echo.
echo ==================================
echo 请选择您的操作:
echo.
echo 按“1” 自动获取IP和DNS
echo 按“2” 自动更改IP为%IP2%
echo 按“3” 自动更改IP为%IP1%
echo 按“4” 手动更改IP和DNS
echo 按“5” 手动设置STTE网络IP和DNS
echo 按“7” Ping测试
echo 按“8” 查看基本IP配置
echo 按“9” 查看完整IP配置
echo 按“f” 返回至CMD窗口
echo 按“r” 修复网卡%NAME%
echo 按“x” 退出
echo.
set /p KEY=您的选择是:
if %KEY% == 1 goto ONE
if %KEY% == 2 goto TWO
if %KEY% == 3 goto THREE
if %KEY% == 4 goto FOUR
if %KEY% == 5 goto FIVE
if %KEY% == 7 goto SEVEN
if %KEY% == 8 goto EIGHT
if %KEY% == 9 goto NINE
if %KEY% == x goto END
if %KEY% == f goto CMD
if %KEY% == r goto RELEASE
echo.
echo 无效的选择参数
goto START
:ONE
ECHO 您选择了自动获取IP和DNS。
ECHO.
echo 正在自动获取IP和DNS......
ECHO.
netsh interface ip set address name=%NAME% source=dhcp
netsh interface ip set dns name=%NAME% source=dhcp
echo.
goto SUCESS
:TWO
ECHO 您选择了自动更改IP为%IP2%。
ECHO.
echo 正在自动更改IP和DNS......
ECHO.
netsh interface ip set address %NAME% static %IP2% %MASK2% %GATEWAY2% 1
netsh interface ip set dns name="%NAME%" source=static addr=%dns1% register=PRIMARY
netsh interface ip add dns name="%NAME%" addr=%dns2% index=2
echo.
goto SUCESS
:THREE
ECHO 您选择了自动更改IP为%IP1%。
ECHO.
echo 正在自动更改IP和DNS......
ECHO.
netsh interface ip set address %NAME% static %IP1% %MASK1% %GATEWAY1% 1
netsh interface ip set dns name="%NAME%" source=static addr=%dns1% register=PRIMARY
netsh interface ip add dns name="%NAME%" addr=%dns2% index=2
echo.
goto SUCESS
:FOUR
ECHO 您选择了手工修改设置。
ECHO.
set IP=%IP2%
set MASK=%MASK2%
set GATEWAY=%GATEWAY2%
set DNS=%DNS1%
set DNS0=%DNS2%
echo 默认IP地址是%IP2%,回车输入默认地址
set /p IP= [请输入IP地址:]
echo.
echo 默认MASK是%MASK2%,回车输入默认值
set /p MASK= [请输入 子网掩码 地址:]
echo.
echo 默认GATEWAY是%GATEWAY2%,回车输入默认值
set /p GATEWAY= [请输入 网关 地址:]
echo.
echo 默认主DNS是%DNS1%,回车输入默认值
set /p DNS= [请输入 DNS 地址:]
echo.
echo 默认辅DNS是%DNS2%,回车输入默认值
set /p DNS0= [请输入 DNS 地址:]
echo.
echo 正在配置IP和DNS......
echo.
netsh interface ip set address %NAME% static %IP% %MASK% %GATEWAY% auto
netsh interface ip set dns name="%NAME%" source=static addr=%DNS% register=PRIMARY
netsh interface ip add dns name="%NAME%" addr=%DNS0% index=2
goto SUCESS
:SEVEN
ECHO 您选择了测试ping命令。
ECHO.
ping 202.96.209.133
echo.
ping
echo.
goto SUCESS
:EIGHT
ECHO 您选择了查看基本IP设置。
ECHO.
IPconfig
echo.
goto SUCESS
:NINE
ECHO 您选择了查看完整IP设置。
ECHO.
IPconfig /all
echo.
goto SUCESS
:RELEASE
ECHO 正在修复网卡%NAME%……
ECHO.
IPconfig /release %NAME%
Ipconfig /renew
echo.
goto SUCESS
:FIVE
ECHO 您选择了手动设置STTE网络配置。
ECHO.
set IP_s=%IP1%
set MASK_s=%MASK2%
set GATEWAY_s=%GATEWAY1%
set DNS=%DNS1%
set DNS0=%DNS2%
goto FIVE_N
:FIVE_NN
echo.
goto FIVE_N
:FIVE_N
echo.
echo 请输入IP地址,如:%IP1%,输入完成后回车确定
set /p IP_s= [请输入IP地址:]
echo.
echo 您输入的IP地址是:%IP_s%,请确认?输入1继续,输入0返回修改
set /p KEY_s=您的选择是:
if %KEY_s% == 1 goto FIVE_Y
if %KEY_s% == 0 goto FIVE_NN
echo.
echo 无效的选择参数
goto FIVE_NN
:FIVE_Y
echo.
echo 正在配置IP和DNS......
echo.
netsh interface ip set address %NAME% static %IP_s% %MASK_s% %GATEWAY_s% auto
netsh interface ip set dns name="%NAME%" source=static addr=%DNS% register=PRIMARY
netsh interface ip add dns name="%NAME%" addr=%DNS0% index=2
goto RELEASE
:SUCESS
echo.
echo 恭喜您,操作成功! :)
echo.
goto START
:END
echo.
exit
:CMD
cmd