标题: [文本处理] 求助批处理中如何提高ping的效率? [打印本页]
作者: lwj96528 时间: 2009-3-21 03:28 标题: 求助批处理中如何提高ping的效率?
自己写了一段批处理,ping不同网段的计算机,但ping到100以上的地址发现速度就很慢......请高手指点如何提高ping的效率.
setlocal EnableDelayedExpansion
for /f "tokens=1,2 delims=;" %%a in (IP2.txt) do (set IP=%%b
echo ------------------------------------->>z.txt
echo #######%%a#########>>z.txt
for /l %%c in (1,1,249) do (ping !IP!%%c -w 1 -n 1 | findstr TTL && echo *****!IP!%%c*****>>z.txt)
)
IP2.txt的内容:
aa办公;20.1.183.1
qq办公;20.1.146.1
ee办公;20.1.158.1
hh办公;20.1.175.1
gg办公;20.1.159.1
作者: Batcher 时间: 2009-3-21 11:35
- @echo off&setlocal enabledelayedexpansion
- if "%1" equ "" (set/a n=-9,m=0&echo %time%) else echo %1 %time%
- for /l %%a in (1 1 4) do if "%1" equ "%%a" goto p1
- for /l %%a in (1 1 4) do (
- set /a n+=10
- set/a m+=10
- start/b %~s0 %%a !n! !m!
- )
- exit
- :p1
- for /l %%i in (%2 1 %3) do (
- title 192.168.18.%%i
- ping /n 1 /w 1 192.168.18.%%i >nul 2>nul&&echo 192.168.18.%%i
- )
- echo %1 %time%
- for /l %%a in (1 1 3) do if "%1" equ "%%a" exit
- rem 加if "%1" equ "%%a"判断,否则 (%终止量%-1)*(%终止量%)=n 退出n次。。。
- pause>nul&exit
复制代码
- @echo off
-
- if [%1]==[] (Goto :Start) else (Goto :Ping)
-
- :Start
- echo.ScanTime:%time%>ip.txt&&set "ip=61.149.20"
- for /L %%i in (1,1,254) do Start %~s0 %ip%.%%i
- Goto :eof
-
- :Ping
- ping %1 -n 1 -w 1 >nul&&echo %1 - OK!>>ip.txt
- exit
复制代码
- @echo off
- type nul>"mac.ini"
- .\arc\nbtscan-1.0.35.exe -m 192.168.10.0/24 | .\arc\sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 >>abc.txt
- setlocal enabledelayedexpansion
- for /f "tokens=1-3 delims= " %%a in (abc.txt) do (
- set mac=%%c
- set mac=!mac::=!
- set cname=%%b
- >>"mac.ini" echo !mac!=%%a,!cname:~10!
- )
- pause
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |