您的位置:首页 > 其它

用批处理来修改IP和DNS,网关等信息

2008-02-20 13:30 701 查看
@echo off
call :select "ip address" "ip"
call :select "Physical Address" "mac"
call :select "Default Gateway" "gateway"
call :select "DNS Servers" "dns"
call :select "Description" "netcard"
echo.
echo.
echo 欢 迎 使 用 网 络 配 置 信 息 查 看 (修改) 器
echo.
color a
echo.
echo.
echo.
echo 本机IP:%ip%
echo 本机MAC:%mac%
echo 本机DNS:%dns%
echo 网关IP:%gateway%
echo 网卡名称:%netcard%
echo.

echo 1.修改IP地址 2.修改网关地址 3.修改DNS地址 4.转到命令行 5.退出

set /p choice=请选择:

if "%choice%"=="1" goto 1
if "%choice%"=="2" goto 2
if "%choice%"=="3" goto 3
if "%choice%"=="4" goto 4
if "%choice%"=="5" goto 5

echo.
:1
set /p IP=请输入IP地址:
netsh interface ip set address name="本地连接" source=static addr=%IP% mask=255.255.255.0

:2
set /p GW=请输入网关地址:
netsh interface ip set address name="本地连接" gateway=%GW% gwmetric=0
:3
set /p DNS=请输入主dns地址
netsh interface ip set dns name="本地连接" source=static addr=%DNS% register=PRIMARY
set slection4=
set /p DNS2=请输入备份dns地址
netsh interface ip add dns name="本地连接" addr=%DNS2%
netsh interface ip set wins name="本地连接" source=static addr=none
:4
@color 07
@%windir%/system32/cmd.exe
@cls
@exit
:5
exit
:select
for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set "%~2=%%i"
GOTO :eof
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: