Board logo

标题: 这个批处理能绑定网关和本机IP吗 [打印本页]

作者: fyb198351     时间: 2007-6-12 01:15    标题: 这个批处理能绑定网关和本机IP吗

@echo off
set server=192.168.0.
arp -d
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 gip=%%g
for /f "tokens=2" %%n in ('ping %gip% -n 1 ^|find "%gip%"') do set gmac=%%n
for /l %%h in (250,1,253) do (
    for /f "skip=3 tokens=2" %%a in ('arp /a %server%%%h') do arp -s %server%%%h %%a)
arp -s %ip% %mac%&&arp -s %gip% %gmac%

看了有几天了写了这个。各位大大位帮忙看下这个批处理能绑定网关,本机IP,还有250-253的IP不

[ Last edited by bjsh on 2007-7-31 at 03:06 PM ]
作者: wangmeng052     时间: 2007-6-12 10:43
了不起啊,几天就会了。向你学习。
作者: zasxcdfv     时间: 2007-6-12 11:37
for /f "tokens=2" %%n in ('ping %gip% -n 1 ^|find "%gip%"') do set gmac=%%n
此句结束后%gamc%=statistics ?

'arp /a %server%%%h'应该是-a吧?

[ Last edited by zasxcdfv on 2007-6-12 at 11:40 AM ]