ping测试批处理(第二版)
ping测试批处理

[codes=dos]@echo off
for /f "delims=" %%a in (data.txt) do  (
echo starttime %date:~0,10% %time% >> %%a.ping
start/b ping %%a -n 2 -l 32 >> %%a.ping
start/b tracert -d %%a >> %%a.tracert
)
:a
set c=0
for /f %%a in ('tasklist^|findstr/i "ping.exe tracert.exe"') do set c=1
if %c%==1 goto a
for /f "delims=" %%a in (data.txt) do  (
echo ===================%%a=================== >> ping.log
type %%a.ping |findstr starttime >> ping.log
type %%a.ping |findstr Packets >> ping.log
type %%a.ping |findstr Minimum >> ping.log
echo. >>ping.log

echo ===================%%a=================== >> tracert.log
type %%a.tracert |findstr %%a >> tracert.log
echo. >>tracert.log
del %%a.ping
del %%a.tracert
)
echo -------------------------------------------------------------------------------- >> ping.log
echo -------------------------------------------------------------------------------- >> ping.log
echo -------------------------------------------------------------------------------- >> tracert.log
echo -------------------------------------------------------------------------------- >> tracert.log[/codes]
过后再增加邮件传送
把ping.log tracert.log结果 以邮件形式发送到指定邮箱

发送邮件参考
cmd下邮件发送工具blat http://selboo.com.cn/Cmd_Maill_Send_Tools/

判断进程是否存在

[codes=dos]@echo off
tasklist /nh|find /i "cmd.exe"
if ERRORLEVEL 1 (echo ok) else (exit)[/codes]
游客 | 登入