@echo off
:start
:: set the size of window
::mode con cols=60 lines=300
cls
echo Time / Date:%time:~0,8% / %date%
echo =========================================
title IP Config by:Waterfrost
color 3f
echo +++By:Waterfrost 2009-10-5++++++++++++++++
echo == [1] Check ipconfig====================
echo == [2] Ping the IP address you set=======
echo == [3] Static IP=========================
echo == [4] Dynamic IP========================
echo == [5] Flush the DNS Resolver Cache======
echo == [0] Enter to exit=====================
echo ==^>
set input=
set /p input=Select(1/2/3/4/5/0):
if "%input%"=="" goto start
echo Your input:%input%
if "%input%"=="1" goto ipcon
if "%input%"=="2" goto pingip
if "%input%"=="3" goto staticip
if "%input%"=="4" goto dynamicip
if "%input%"=="5" goto flush
if "%input%"=="0" exit
goto start
:flush
ipconfig /flushdns
pause
goto start
:ipcon
title Ipconfig
color 2e
ipconfig /all
pause
goto start
:pingip
Title Ping ip
color 2e
set ip=
set times=2
set /p ip=The ip you want to ping(q to menu):
if /i "%ip%"=="q" goto start
if "%ip%"=="" goto pingip
echo 1.The times of ping
echo 2.Ping without stopping
echo Default times of ping is 2
set /p times=Select(1/2):
if "%times%"=="1" goto pingtimes
if "%times%"=="2" goto pingwithoutstop
pause
goto start
:pingwithoutstop
title Ping %ip% no stop
ping %ip% -t
pause
goto start
:pingtimes
set /p counts=Input the times:
title Ping %ip% (%counts% times)
ping %ip% -n %counts%
pause
goto start
:staticip
title Static ip
color 4f
::get dns
for /f "tokens=1* delims=:" %%a in ('ipconfig /all^|find "dns servers" /i') do set dns=%%b
set eth="本地连接"
::set default submask
set localip=
set localsubmask=
set localgateway=
set staticip=
set submask=
set gateway=
::get ip,submask,gateway of current networkset
for /f "tokens=1* delims=:" %%a in ('ipconfig /all ^|find "ip address" /i') do set localip=%%b
for /f "tokens=1* delims=:" %%a in ('ipconfig /all ^|find "subnet mask" /i') do set localsubmask=%%b
for /f "tokens=1* delims=:" %%a in ('ipconfig /all ^|find "default gateway" /i') do set localgateway=%%b
echo;
echo ***ip****************************
echo 1.Use current ip.Curren ip:%localip%
echo 2.Input ip
:choice
set choice=
set /p choice=Your choice(1,2):
if "%choice%"=="" goto choice
if "%choice%"=="1" goto current
if "%choice%"=="2" goto input
goto choice
:current
if "%localip"=="" (echo localip empty &goto choice)
set staticip=%localip%
goto submask
:input
set /p staticip=Input ip address,format:X.X.X.X(q to menu):
if "%staticip%"=="" goto input
if "%staticip%"=="q" goto start
:submask
echo;
echo ***subnet mask*******************
echo 1.Use Current submask.Current subnet mask:%localsubmask%
echo 2.Use Default submask.Default:255.255.255.0
echo 3.Input submask
:subchoice
set subchoice=
set /p subchoice=Your choice(1,2,3):
if "%subchoice%"=="" goto subchoice
if "%subchoice%"=="1" goto currentsub
if "%subchoice%"=="2" goto defaultsub
if "%subchoice%"=="3" goto inputsub
goto subchoice
:currentsub
if "%localsubmask"=="" (echo localsubmask empty & goto subchoice)
set submask=%localsubmask%
goto gateway
:defaultsub
set submask=255.255.255.0
goto gateway
:inputsub
set /p submask=Input subnet mask:
if "%submask"=="" goto inputsub
goto gateway
:gateway
::Get default gateway
for /f "tokens=1-4 delims=." %%a in ('echo %staticip%') do set gateway=%%a.%%b.%%c.1
echo;
echo ***gateway************************
echo 1.Use current gateway.Current gateway:%localgateway%
echo 2.Use default gateway.Default gateway:%gateway%
echo 3.Input gateway
:gatewaychoice
set gatewaychoice=
set /p gatewaychoic=Your choice(1,2,3):
if "%gatewaychoic%"=="" goto gatewaychoice
if "%gatewaychoic%"=="1" goto currentgate
if "%gatewaychoic%"=="2" goto defaultgate
if "%gatewaychoic%"=="3" goto inputgate
goto gatewaychoice
:currentgate
if "%localgateway"=="" (echo localgateway empty & goto gatewaychoice)
set gateway=%localgateway%
goto setip
:defaultgate
set gateway=%gateway%
goto setip
:inputgate
set /p gateway=Input gateway:
if "%gateway%"=="" goto inputgate
goto setip
:setip
echo Please wait about 20s
netsh interface ip set address %eth% static %staticip% %submask% %gateway% 1
:setstaticdns
echo Get the Dns of ipconfig(no content means no dns)
echo Default dns:%dns%
echo Do you want to change dns(Default N)
set ask=N
set /p ask=Select(Y/N):
if /i %ask%==y set /p dns=Input dns:
if /i %ask%==y (if /i "%dns%"=="" goto setstaticdns)
if /i %ask%==y netsh interface IP set dns %eth% static %dns%
ipconfig /all
pause
goto start
:dynamicip
title Dynamic IP
set eth="本地连接"
set ask=
echo Do you want to dynamic ip(q to menu)
set /p ask=Select(Y/N/Q):
if "%ask%"=="" goto dynamicip
if /i "%ask%"=="q" goto start
if /i "%ask%"=="y" netsh interface ip set address "%eth%" source=dhcp
:dynamicdns
echo Do you want to dynamic DNS(q to menu)
set asks=
set /p asks=Select(Y/N/Q):
if "%asks%"=="" goto dynamicdns
if /i "%asks%"=="q" goto start
if /i "%asks%"=="y" netsh interface ip set dns "%eth%" source=dhcp
ipconfig /all
pause
goto start