星期四, 五月 15, 2008

解除IP和网卡mac绑定的批处理命令

你可以通过开机自动运行以下批处理来解决这个问题

@echo off
if exist ipconfig.txt del ipconfig.txt
ipconfig /all >ipconfig.txt

if exist GateIP.txt del GateIP.txt
find "Default Gateway" ipconfig.txt >GateIP.txt
for /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G

:::::::::读取网关Mac地址
if exist GateMac.txt del GateMac.txt
arp -a %GateIP% >GateMac.txt
for /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H
:
::::::::绑定网关Mac和IP
arp -s %GateIP% %GateMac%

del GateIP.txt
del ipconfig.txt
del GateMac.txt

exit

0 评论: