Board logo

标题: 本人一直在也用的客户端绑定MAC地址批命令【原创】 [打印本页]

作者: zhqw     时间: 2007-11-6 11:25    标题: 本人一直在也用的客户端绑定MAC地址批命令【原创】

把下面内容另存为RARP.BAT,存入启动组里 @Echo off set times=1 set loop=0 set c=2f color %c% arp -d > nul cls echo. echo. echo 正在绑定本机、网关的IP与MAC地址,请稍候......完成后本窗口自动关闭。 :TryAgain For /f "delims=: tokens=2" %%i in ('ipconfig /all^|find /i "IP Address"') do set IP=%%i For /f "delims=: tokens=2" %%m in ('ipconfig /all^|find /i "Physical Address"') do set MAC=%%m For /f "delims=: tokens=2" %%g in ('ipconfig /all^|find /i "Default Gateway"') do Set GateIP=%%g ping %GateIP% -n 1 For /f "tokens=2" %%n in ('arp -a^|find "%GateIP%"') do Set GateMAC=%%n if Not Errorlevel==1 goto SetMAC set /a loop=%loop%+1 if /i %loop% LSS 3 goto TryAgain set loop=0 if /i %times% GTR 3 goto fail cls echo. echo. set KEY=Exit echo ======================== 第 %times% 次连接网关失败! ======================== echo 没有找到网关%GateIP%的MAC地址,重试请按【R】键,退出请按【Enter】键 if %c%==9f (set c=2f) else set c=9f color %c% set /a times=%times%+1 echo. set /p KEY= 请选择按键: if /i %KEY% == R goto TryAgain goto fail :SetMAC arp -s %IP% %MAC% arp -s %GateIP% %GateMAC% exit :fail cls color ce echo. echo. echo. echo 无法正确绑定网关的IP和MAC地址,请稍候再试......,按任意键关闭程序窗口。 PAUSE >NUL Exit [ Last edited by zhqw on 2007-11-6 at 11:29 AM ]

作者: mayu2004     时间: 2008-1-7 08:44
很好 我也写了 个 不过我 的 没有容错