網管或進階用戶常需在DHCP故障排查、網段規劃時,快速掃描某IP範圍內哪些位址尚未被佔用。Windows XP命令列配合批次檔即可輕鬆實現,避免在命令視窗翻閱大量Ping回應。

直接在CMD下輸入:
For /L %f in (1,1,100) Do Ping.exe -n 2 192.168.1.%f
會列出192.168.1.1~100所有位址的回應,人工辨識極不效率。改寫為批次檔IPTracker.bat,只輸出「請求逾時」的位址並寫入文字檔:
IPTracker.bat)@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 cls Echo Finished! @Echo on Notepad.exe IPList.txt
關鍵點:
For...Do命令必須寫在同一行,以&&串接多條指令。%%f(非%f)。192.168.1.x替換為實際網段。雙擊執行後,自動彈出IPList.txt,內含掃描時間戳記與所有「無回應」的IP清單,一目瞭然。Windows 7/10同樣適用,僅需注意權限與路徑差異。