Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows XP 批次腳本掃描 DHCP 範圍內未使用 IP:IPTracker.bat 一鍵輸出記事本

編輯:XP 系統基礎知識

需求:快速找出 192.168.1.1~100 哪些 IP 閒置

手工 ping 逐個測試太慢,且輸出雜訊多。寫批次檔只回報「Request timed out」的 IP,並存成文字檔。

IPTracker.bat 完整內容

@echo off
date /t > IPList.txt
time /t >> IPList.txt
echo =========== >> IPList.txt
for /L %%f in (1,1,100) do (
  ping -n 2 192.168.1.%%f | find "Request timed out." >nul && echo 192.168.1.%%f Timed Out >> IPList.txt
)
cls
echo Finished!
notepad IPList.txt

注意:for 迴圈與 find 需在同一行(以 && 串接),IP 範圍自行修改。

使用方式

  1. 記事本貼上上述碼 → 存為 IPTracker.bat。
  2. 雙擊執行 → 自動掃描 → 開啟記事本顯示未使用 IP 清單(含日期時間戳記)。
  3. 可重複使用,下次直接雙擊即可。

適用限制

  • 僅限 Windows XP Professional(Home 版無 gpedit.msc 但批次檔仍可跑)。
  • 需 ICMP 回應未被防火牆封鎖。
  • 大範圍掃描耗時較久,建議縮小範圍或改用專用 IP 掃描工具(如 Advanced IP Scanner)。

結語

一個批次檔解決 DHCP 閒置 IP 盤點,免安裝工具、輸出純文字好閱讀,網管小工具箱必備。

Copyright © Windows教程網 All Rights Reserved