[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
这样试
  1. @echo off
  2. set nic=本地连接
  3. for /f "skip=1" %%i in ('wmic Nic where "NetConnectionID='%nic%'" get MACAddress^,NetConnectionID 2^>^&1') do (
  4.     for %%a in (%%i) do set "mac=%%a"
  5. )
  6. if not defined mac (
  7.    set "nic="
  8.    for /f "skip=1tokens=*" %%i in ('wmic Nic get MACAddress^,NetConnectionID') do (
  9.        for /f "tokens=1*" %%a in ("%%i") do (
  10.            if "%%~nxb" neq "" (
  11.               set mac=%%a&set "nic=%%~nxb"
  12.            ) else if not defined mac set mac=%%a
  13.        )
  14.    )
  15. )
  16. set ip=
  17. if not defined nic set nic=本地连接
  18. if defined mac for /f "tokens=2" %%a in ('findstr /ibc:"%mac%" 1.txt') do set "ip=%%a"
  19. if not defined ip echo,没有ip可匹配&pause&exit
  20. set mask=255.255.255.0
  21. set gateway=192.168.0.1
  22. set dns=21.156.240.1
  23. netsh interface ip set address "%nic%" static %ip% %Mask% %gateway% 1 >nul 2>nul
  24. netsh interface ip set dns "%nic%" static %dns% >nul 2>nul
  25. pause
复制代码

TOP

回复 3# wangxiaodong
把下面两行 改为 看什么提示
  1. netsh interface ip set address "%nic%" static %ip% %mask% %gateway% 1
  2. netsh interface ip set dns "%nic%" static %dns%
复制代码

TOP

回复 6# wangxiaodong
这个是屏蔽去掉吧

TOP

返回列表