- @echo off
- if exist physical.txt del /f /q physical.txt >>nul
- set /a number=0
- ipconfig /all |findstr /i "Physical" >>physical.txt
- setlocal ENABLEDELAYEDEXPANSION
- for /f "delims=: tokens=2" %%i in (physical.txt) do (
- set str=%%i
- set "str=!str: =!"
- :Next
- if not "!str:~%number%,1!"=="" (
- set /a number+=1
- goto :Next )
- if !number! equ 17 set /a macnum+=1
- set /a number=0
- )
- echo %macnum%
- pause
复制代码 原本是想打算通过MAC address来计算出当前系统的物理网卡,先用关键字取出带physical的字符串,再判断长度是否为17,则可以断定当前的字符串代表的是一个MAC地址,然后计数加1. 可循环一次后就退出来了,不明白哪里出问题了 |