代码如下: if exist ipconfig.txt del ipconfig.txt ipconfig /all >ipconfig.txt if exist phyaddr.txt del phyaddr.txt find "Physical Address" ipconfig.txt >phyaddr.txt for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M if exist IPAddr.txt del IPaddr.txt find "IP Address" ipconfig.txt >IPAddr.txt for /f "skip=2 tokens=15" %%I in (IPAddr.txt) do set IP=%%I find "Default Gateway" ipconfig.txt >IPAddr2.txt for /f "skip=2 tokens=13" %%N in (IPAddr2.txt) do set Gate=%%N arp.exe -s %IP% %Mac% arp.exe -s %Gate% 00-04-80-3b-1b-00 del ipconfig.txt del phyaddr.txt del ipaddr.txt del ipaddr2.txt exit