局域网IP设置

将以下内容复制粘贴至记事本,另存,将文件名后缀改为bat即可

@echo off
@color 1F
@title 欢迎进入********局域网 ! ! !

chcp 437>nul&graftabl 936>nul
cls
if %1#==# (
set /p name=请输入使用者姓名[可以用拼音或汉字]:
) else set name=%1
(for /F "usebackq eol=# tokens=1,2,3 " %%i in (`type IP.inf ^| find /i "%name:'=%"`) do (set ip=%%k& set name=%%i& echo %%j的IP地址为 %%k)) &&goto set|| echo 配置文件中没找到%name%的IP地址!&&set ip=0
set /p ch=MY:自行设定IP地址; 其他任意值将返回重新输入请选择[MY或其他]?
if /i "%ch%" NEQ "MY" %0
:input
set /p ip=请输入IP地址:10.141.47.
if "%ip:~0,1%"=="-" (WRITEXT 0+ 1 -f10 -b5 输入错误!!!
goto input)
:clean0
if "%ip:~0,1%"=="0" (set ip=%ip:~1%
goto clean0)
:set
set ip=%ip:~-3%
if %ip:.=% LSS 1 %0
if %ip:.=% GEQ 255 %0
for /F "usebackq tokens=1,2,3 " %%i in (`ipconfig ^| findstr /i /c:"ethernet adapter"`) do set eth=%%k
ECHO 设置"%eth::=%"属性
netsh interface ip set address name="%eth::=%" source=static addr=10.141.47.%ip:.=% mask=255.255.255.0 gateway=10.141.47.2 gwmetric=1 >nul && WRITEXT 0+ 1 -f10 -b5 IP地址设置成功) || %0
netsh interface ip set dns "%eth::=%" static 10.141.30.1 >nul && netsh interface ip add dns "%eth::=%" 10.41.1.41 >nul && netsh interface ip add dns "%eth::=%" 10.41.1.42 >nul && WRITEXT 3+ 1 -f10 -b5 DNS设置成功 ||WRITEXT 3+ 1 -f10 -b5 DNS设置失败
pause
netsh interface ip show address
echo.
echo ━━┳━━ ┏━━┓
echo ┏━╋━┓ ┃┃┃┃
echo ┃━╋━┃ ┃┃┃┃
echo ╋━┻━╋ ┃┃┃┃
echo ┃ ┃ ━━┛┗━┛

相关主题
相关文档
最新文档