
我们可以使用Windows内置的ipconfig命令来获取IP地址。在bat脚本中,可以使用以下代码来获取IP地址:
for /f "delims=: tokens=2" %%i in ('ipconfig ^| findstr /i "IPv4 Address"') do (set ip=%%iset ip=!ip:~1!)
要获取MAC地址,我们可以使用Windows的getmac命令。在bat脚本中,可以使用以下代码来获取MAC地址:
for /f "tokens=2 delims==" %%a in ('getmac /fo csv /nh') do (set mac=%%agoto done):done
通过以上两种方法,我们就可以在bat脚本中轻松地获取本机的IP和MAC地址,并在后续的脚本中使用这些信息。这种方法非常简单实用,适用于Windows系统下的各种自动化脚本。
求一个bat脚本能够获取到本机所有网卡的mac地址
WINDOWS系统,已知本地的IP,如何通过命令找到IP地址对应的MAC地址?
以下代码复制粘贴到记事本,另存为,编码选ANSI@echo offrem 根据本地的ip地址查找对应的mac地址/物理地址set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4title %#% +%$%%$%/%_% %z%set ip=192.168.1.2wmic nicconfig get IPAddress,MACAddress|findstr \%ip:.=\.%\echo;%#% +%$%%$%/%_% %z%pauseexit
BAT-批处理-怎样提取MAC地址并保存
楼主第2问我没看懂,下面给出代码,如果不是楼主想要的,就HI我吧。@echo offsetlocal enabledelayedexpansionfor /f tokens=1-2 delims=: %%i in (ipconfig /all ^|findstr Physical Address) do (set jieguo=%%jecho !jieguo!|find - && goto next ):nextset mac=!jieguo:-=!echo 123>> 我的MAC地址为:%mac: =%>>-GO网络知道团队--xie3331