批处理mac

来源:百度知道 编辑:UC知道 时间:2024/06/07 11:55:21
通过命令 getmac 获取本机的mac地址
笔记本下会出现2-3个MAC地址,全部保存为1.txt
-----------------------------------------------------
第2个问题是通过getmac获取mac地址与1.txt 里面比较
如果出现一个相同就goto s
(1.txt里面最多3行)

问题1:
@echo off
if exist "1.txt" ren "1.txt" "[%random%]1.txt"
for /f "tokens=1,2 delims= " %%a in ('getmac^|find /i "-"') do echo %%a>>1.txt
exit

问题2:
@echo off
for /f "tokens=1,2 delims= " %%a in ('getmac^|find /i "-"') do (
For /f "delims=" %%i in ('type "1.txt"^|find /i "%%a"') do goto s
)
exti
:s
echo 有相同。
pause

这样??!

1、
@for /f "skip=3" %%i in ('getmac')do echo %%i>>1.txt

2、
@echo off
for /f "skip=3" %%i in ('getmac')do findstr/c:"%%i" 1.txt&&goto s
pause&exit
:s

@echo off
for /f "skip=3 tokens=1 delims= " %%a in ('getmac') do (
echo %%a>>1.txt
)

===========================================
@echo off
for /f &quo