rem ip和设备名称一一族肢对应按格式添加在bat代码最后盯键
set now=%date% %time%
set "result=report.txt"
>report.txt echo%now%
for /f "tokens=1 delims=:" %%a in ('findstr /in "^exit" "%~f0"') do set n=%%a
for /f "tokens=1*" %%i in ('more +%n% "%~f0"') do (
ping -w 1 -n 兆则世2 %%i|>nul find /i "ttl="&&(set status=OK)||set status=NO
set "name=%%j"
setlocal enabledelayedexpansion
echo!name!/!status!
>>"%result%" echo!name!/!status!
endlocal
)
start "" "%result%"
exit
192.168.1.1 设备1
192.168.1.2 设备a
192.168.1.3 设备x
192.168.1.4 设备666
……
@echo Off & setlocal Enabledelayedexpansion & mode 65,15set "file_name=123.txt"
set str_begins=6
set str_end=29
set/a str_begin=str_begins-1
>>$ (
for /f "delims=" %%a in (!file_name!) do (
set/a fime_step+=1
set str= & 闹银set "str=%%a"
echo !str:~0,1!))
>>$1 (
for /f "delims=" %%a in ($) do <nul set /p=%%a)
move $1 $ & set fime_step= & cls
>>Password.txt (
for /f "delims=" %%a in ($) do (
set "file_str=%%a"
echo !file_str:~%str_begin%,%str_end%!))
dEl $ &睁凯 exit
:: str_begins 是起始数值
:: str_end 是结束数值
:: 代码最终是悉弯唤将 6 至 29 行的首字符提取出来保存至 Password.txt 文本中
:: 中国批处理脚本联盟
假定你的原批处理是a.bat在dos模式下输入:
a.bat >>c:\result.txt [回车]
或你再做一个批处理b.bat
b.bat中写作:
a.bat >>c:\result.txt
运行b.bat就可把a.bat的运行结果写在c:\result.txt
=================
我测毁尘试过的,没有你说的情况发缓芹生啊
也许你的批处理文扰余毕件比较特别吧!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)