xp下自动绑定ip和网关,并在生产自动绑定的启动项!
@echo off
REM xp下自动批处理
REM 绑定本机IP地址和MAC
:start
if exist ipconfig.txt del /f ipconfig.txt
ipconfig /all>ipconfig.txt
find /i "physical address" ipconfig.txt>phyaddr.txt
for /f "skip=2 tokens=12 " %%i in (phyaddr.txt) do set MAC=%%i && goto IP
:IP
echo 物理地址:%MAC%
del /f phyaddr.txt
if exist ipaddr.txt del /f ipaddr.txt
find /i "ip address" ipconfig.txt>ipaddr.txt
for /f "skip=2 tokens=15 " %%i in (ipaddr.txt) do set IP=%%i && goto bind
:bind
echo ip地址:%IP%
del /f ipaddr.txt
arp -s %IP% %MAC%
REM 绑定网关和MAC
if exist gatewayaddr.txt del /f gatewayaddr.txt
find /i "default gateway" ipconfig.txt>gatewayaddr.txt
for /f "skip=2 tokens=13 " %%i in (gatewayaddr.txt) do set GATEIP=%%i && goto gatemac
:gatemac
echo 网管ip:%GATEIP%
del /f gatewayaddr.txt
for /f "skip=3 tokens=2 " %%i in ('arp -a %GATEIP%') do set GATEMAC=%%i && goto bind2
:bind2
echo %GATEMAC%
arp -s %GATEIP% %GATEMAC%
del /f ipconfig.txt
@echo arp -s %IP% %MAC%>"%SYSTEMDRIVE%\Documents and Settings\All Users\「开始」菜单\程序\启动\arp绑定.bat"
@echo arp -s %GATEIP% %GATEMAC%>>"%SYSTEMDRIVE%\Documents and Settings\All Users\「开始」菜单\程序\启动\arp绑定.bat"

最新回复