排查 DHCP 故障時需找出指定範圍內未使用的 IP。傳統 for 迴圈 ping 需人工檢視大量輸出。改寫批次檔自動過濾僅顯示未回應 IP 並存檔。
記事本輸入以下內容(單行):
@Echo off
date /t > IPList.txt
time /t >> IPList.txt
echo =========== >> IPList.txt
For /L %%f in (1,1,100) Do Ping.exe -n 2 192.168.1.%%f Find "Request timed out." && echo 192.168.1.%%f Timed Out >> IPList.txt && echo off
cls
Echo Finished!
@Echo on
Notepad.exe IPList.txt
存為 IPTracker.bat。需將範例 IP 替換為實際網段。執行後自動開啟記事本顯示未使用 IP 清單,可重複使用。
注意:僅適用 Windows XP Professional 版本。