标题: 本机与网关mac绑定工具 求高手优化代码
[打印本页]
作者: mayu2004
时间: 2008-1-7 08:37
标题: 本机与网关mac绑定工具 求高手优化代码
求助 哪位 能优化 一下 代码 或者 不产生 临时文件
@echo off
title Mac地址绑定程序
::QQ 236189165
mode con cols=25 lines=6
echo.正在解析函数请稍等...
:: 解析函数代码来自:3742668 代码修订:namejm
call :select "ip address" "ip"
call :select "Physical Address" "mac"
call :select "Default Gateway" "gateway"
goto begin
:select
for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set "%~2=%%i"
goto :eof
:begin
cls
::----------------本机绑定-------------
echo.正在自动绑定请稍等......
arp -d >nul 2>nul
arp -s %ip% %mac% >nul
ping %gateway% >nul
::-------------------网关绑定-----------------
arp.exe -a >arp.txt
find "%gateway%" arp.txt>mac.txt
for /f "skip=2 tokens=2" %%Z in (mac.txt) do set Mac=%%Z
arp -s %gateway% %Mac% >nul
del arp.txt&del mac.txt
cls
echo.****绑定完毕 2秒退出****
ping 127.255.255.255 -n 1 -w 2000>nul