欢迎来到福编程网,本站提供各种互联网专业知识!

wind7批处理设置IP(脚本)

发布时间:2013-03-16 作者:clown_ 来源:互联网
wind7批处理设置IP(脚本)说明:在x.x.x.x处填上自己的IP地址。保存成“.bat”文件,以管理员身份运行即可。代码如下:@echooff:mainclsecho请按提示操作...echo.echo1STI-HUSTecho2Dian-HUST-711echo3DHCPecho4Exitecho.set/pchoice=Inputanumber:e

wind7批处理设置IP(脚本)

说明:在x.x.x.x处填上自己的IP地址。

保存成“.bat”文件,以管理员身份运行即可。

代码如下:

@echo off

:main

cls

echo 请按提示操作...

echo.

echo 1 STI-HUST

echo 2 Dian-HUST-711

echo 3 DHCP

echo 4 Exit

echo.

set /p choice= Input a number:

echo.

if "%choice%"=="1" goto ip_STI

if "%choice%"=="2" goto ip_Dian711

if "%choice%"=="3" goto ip_DHCP

if "%choice%"=="4" goto ip_Exit

goto main

:ip_STI

echo IP自动设置中...

echo.

echo 更新IP及子网掩码

netsh interface ip set address name="本地连接" source=static addr=x.x.x.x mask=x.x.x.x gateway=x.x.x.x gwmetric=1

echo 更新DNS服务器

netsh interface ip set dns name="本地连接" source=static addr=x.x.x.x register=PRIMARY

netsh interface ip add dns name="本地连接" addr=x.x.x.x

echo 设置完成

pause

exit

if errorlevel 2 goto main

if errorlevel 1 goto end

:ip_Dian711

echo IP自动设置中...

echo.

echo 更新IP及子网掩码

netsh interface ip set address name="本地连接" source=static addr=x.x.x.x mask=x.x.x.x gateway=x.x.x.x gwmetric=1

echo 更新DNS服务器

netsh interface ip set dns name="本地连接" source=static addr=x.x.x.x register=PRIMARY

netsh interface ip add dns name="本地连接" addr=x.x.x.x

echo 设置完成

pause

exit

if errorlevel 2 goto main

if errorlevel 1 goto end

:ip_DHCP

netsh interface ip set address name="本地连接" source=dhcp

netsh interface ip set dns name="本地连接" source=dhcp

netsh interface ip set wins name="本地连接" source=dhcp

echo 设置完成

pause

exit

if errorlevel 2 goto main

if errorlevel 1 goto end

:ip_Exit

exit

相关推荐