網管需找出 DHCP 範圍內哪些 IP 尚未被使用,僅回報可用 IP 並輸出文字檔,避免逐行人工檢視龐大 Ping 結果。
IPTracker.bat,內容如下 (單行輸入 For 迴圈):@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
192.168.1 替換為實際網段,(1,1,100) 調整為起始、遞增、結束值IPList.txt 僅顯示逾時 (未使用) 的 IPFor /L %%f in (1,1,100):1 到 100 步進 1 迴圈Ping -n 2:發送 2 個封包加速判斷Find "Request timed out.":篩選無回應 (未使用) 的 IP&& 串聯:僅當 Find 成功時記錄 IP 到檔案