【成品】---批处理设置IP地址

手动设置
@echo off

echo By:CatcherX

echo Date:2013-03-17

echo

echo

echo

echo 请选择接口名称:

set /p Check=0.手动输入,1."本地连接",2,"8187":  

if /i %Check% equ 1 goto LocalLnk

if /i %Check% equ 2 goto 8187

if /i %Check% equ 0 goto InPut

:LocalLnk

set eth="本地连接"

goto z

:8187 

set eth="8187"

goto z

:Input

set /p eth=Please Input EthName(eg:本地连接):

goto z

:Z

echo %eth%

set /P ip=Please Input IP:

set /p gw=Please Input GateWay:

set /p netmasks=Please Input NetMask:

set /p dns1=Please Input DNS1:

set /p dns2=Please Input DNS2:

echo 正在将本机IP更改到:%ip%

netsh interface ip set address "%eth%" static %ip% %netmasks% %gw% 1

echo 正在添加本机主DNS:%dns1%

netsh interface ip set dns "%eth%" static %dns1%

echo 正在添加本机副DNS:%dns2%

netsh interface ip add dns "%eth%" %dns2%

echo ------------------------------

echo   IP更改完毕,检查当前配置...

echo ------------------------------

ipconfig /all

pause

close
自动获取
@echo off

echo By:CatcherX

echo Date:2013-03-17

rem eth       //设置网卡名称,如"本地连接"

set eth="本地连接"

rem sleep     //设置后面的等待时间,如"20秒"

set sleep=ping -n 18 127.0.0.1>nul 2>nul

echo 正在更改为自动获取IP地址...

netsh interface ip set address "%eth%" source=dhcp

echo 正在更改为自动获取DNS地址...

netsh interface ip set dns "%eth%" source=dhcp

echo --------------------------------------

echo   更改完毕,正在自动获取IP,等待20秒

echo --------------------------------------

%SLEEP%

echo ----------------------------------------

echo   检查当前IP

echo ----------------------------------------

ipconfig /all

pause

close

 

你可能感兴趣的:(IP地址)