Board logo

标题: [网络连接] 批处理如何增加未找到mac地址的提示,例如:未找到自此台计算机? [打印本页]

作者: wen23t    时间: 2013-11-28 09:53     标题: 批处理如何增加未找到mac地址的提示,例如:未找到自此台计算机?

  1. @echo off
  2. echo 正在配置IP地址、DNS请稍候……
  3. set MASK=255.255.255.0
  4. set GATEWAY=192.168.103.254
  5. set DNS1=202.96.128.143
  6. set DNS2=202.96.128.68
  7. set WINS=192.168.103.254
  8. for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do set mac=%%i
  9. more +22 "%~f0" | findstr "%mac%" || pause && goto :eof
  10. for /f "tokens=1,2*" %%i in ('ipconfig /all^|find "Ethernet adapter"')  do set Ethernet=%%k
  11. for /f "tokens=1,2" %%i in ('more /e +22 %0 ^|find /i "%mac:~,-1%"') do set "name=%%i"&set "IP=%%j"
  12. for /f "tokens=4" %%j in ('more /e +22 %0 ^|find /i "%mac:~,-1%"') do set "p=%%j"
  13. reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\lanmanserver\parameters" /v srvcomment /t reg_sz /d %p% /f >nul 2>nul
  14. reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters" /v srvcomment /t reg_sz /d %p% /f >nul 2>nul
  15. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
  16. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
  17. reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
  18. netsh interface ip set address "%Ethernet:~,-2%" static %IP% %Mask% %GATEWAY% 1 >nul 2>nul
  19. netsh interface ip set dns "%Ethernet:~,-2%" static %DNS1% register=PRIMARY >nul 2>nul
  20. netsh interface ip add dns "%Ethernet:~,-2%"  %DNS2% index=2 >nul 2>nul
  21. netsh interface ip set wins "%Ethernet:~,-2%" static %WINS%  >nul 2>nul
  22. exit
  23. A01 192.168.103.101 10-60-4b-77-fe-a0 北三楼A01
  24. A02 192.168.103.102 10-60-4b-8b-50-be 北三楼A02
  25. A03 192.168.103.103 10-60-4b-88-61-7f 北三楼A03
  26. A04 192.168.103.104 10-60-4b-88-70-a6 北三楼A04
  27. A05 192.168.103.105 10-60-4B-89-46-CE 北三楼A05
  28. A06 192.168.103.106 10-60-4b-8b-51-3f 北三楼A06
  29. A07 192.168.103.107 10-60-4b-8b-53-cd 北三楼A07
  30. A08 192.168.103.108 10-60-4b-8b-51-38 北三楼A08
  31. A09 192.168.103.109 10-60-4b-77-e5-c4 北三楼A09
  32. A10 192.168.103.110 10-60-4b-77-ea-c2 北三楼A10
  33. B01 192.168.103.111 10-60-4b-77-e7-e6 北三楼B01
  34. B02 192.168.103.112 10-60-4b-77-fe-80 北三楼B02
  35. B03 192.168.103.113 10-60-4b-88-5e-cc 北三楼B03
  36. B04 192.168.103.114 10-60-4b-77-ea-a9 北三楼B04
  37. B05 192.168.103.115 10-60-4b-77-fe-9e 北三楼B05
  38. B06 192.168.103.116 10-60-4b-77-e7-eb 北三楼B06
  39. B07 192.168.103.117 10-60-4b-88-70-a1 北三楼B07
  40. B08 192.168.103.118 10-60-4b-8b-50-99 北三楼B08
  41. B09 192.168.103.119 10-60-4b-86-2f-d2 北三楼B09
  42. B10 192.168.103.120 10-60-4b-77-fe-f4 北三楼B10
复制代码

作者: apang    时间: 2013-11-28 10:28

本帖最后由 apang 于 2013-11-28 10:29 编辑

more +22 "%~f0" | findstr "%mac%" ||(echo,未找到 & pause & goto :eof)
作者: wen23t    时间: 2013-11-28 10:32

谢谢十分感谢




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2