Batch file 从arp-a命令获取设备的完整列表

Batch file 从arp-a命令获取设备的完整列表,batch-file,networking,arp,Batch File,Networking,Arp,我制作了一个(非常)简单的批处理文件: @echo off :start arp -a | findstr 20-7c-8f-3f-03-9c cls if %errorlevel% GEQ 1 ( echo The device is offline Echo Device is offline at %time% on %date%. >> log.txt ) else ( echo The device is online. Echo Device is online at %

我制作了一个(非常)简单的批处理文件:

@echo off
:start
arp -a | findstr 20-7c-8f-3f-03-9c
cls
if %errorlevel% GEQ 1 (
echo The device is offline
Echo Device is offline at %time% on %date%. >> log.txt
) else (
echo The device is online.
Echo Device is online at %time% on %date%. >> log.txt
)
timeout 3 >nul /nobreak
goto start
虽然这种方法很好用,但如果上面提到的设备没有列出,也就是手机,它就不起作用了

这就是我的意思

连接到我的路由器的所有设备都不会显示在
arp-a
输出中。假设我的ipod的Mac地址是
18:E7:F4:86:75:9F
。是否有其他方法检测它是否在LAN上?或者我应该只使用其他软件。我喜欢使用它,并且它总是在后台运行。这将是一个非常有用的工具。我可以知道我父母什么时候回家,或者我认识的人是否在我家。它将作为一个懒惰的安全程序。只是想一些想法和潜力


使用Nmap是否更好?

我找到了解决这个问题的迂回方法。它不一定能解决我的问题,它只是让我的程序工作。它使用名为的工具,并使用其命令行功能。我基本上是将程序屏幕上的所有内容打印到file.txt,然后扫描file.txt以查找mac地址。在整个过程中循环大约需要7秒钟,但它完成了任务

代码:


如果能有另一个答案,也就是说,为什么我的ipod没有出现?

你不需要临时文件:
wnetwatcher.exe | find“18-E3-A4-86-75-9C”>nul&&echo online | echo offline
should.wnetwatcher.exe启动GUI程序。无法将结果显示在命令输出中。
@echo off
echo gathering info . . .
:start
if exist info.txt del info.txt
wnetwatcher.exe /stext info.txt
:loop
if exist "info.txt" (
goto aaa
)
timeout 2 >nul /nobreak
goto loop

:aaa
cls
find info.txt "18-E3-A4-86-75-9C" >nul
if %errorlevel% GEQ 1 (
color c0
echo.
echo.

echo.    Cole's iPod is offline.
) else (
color a0
echo.
echo.
echo.    Cole's iPod is online.
)
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Refreshing (7s)
goto start