回复 28# 再世情緣
经过几天学习和你的教导,我更改的最终版本是这样的。
一共分三部分: 如代码执行效率有不完善的地方,请多多赐教。
第一部分,文件生成!(count.bat) | @echo off &color 0a &setlocal enabledelayedexpansion | | pushd "%cd%" | | :main | | sures sures >sures.txt | | for /f "tokens=1,2,3,4 delims==" %%a in (config.txt) do ( | | set /a "i=0","j=0" | | set "name=%%a" &set "tk1=%%b" &set "tk2=%%c" &set "t=%%d" | | if not exist "%computername%_!name!.txt" (echo.data time computername !name!^<Inuse^>^/^<Available^>)>"%computername%_!name!.txt" | | for /f "delims=" %%1 in ('findstr /i /c:"!tk1!" "sures.txt" ^>nul 2^>nul') do (set /a "i+=1") | | for /f "delims=" %%1 in ('findstr /i /c:"!tk2!" "sures.txt" ^>nul 2^>nul') do (set /a "j+=1") | | (echo.%date:~0,10% %time:~0,8% %computername% !i!^/!j!)>>"%computername%_!name!.txt" | | ) | | ping localhost -n %t% >nul 2>nul | | cls &goto :mainCOPY |
第二部分:参数配置(config.txt)
agent=_12 RES IN USE=_12 RES AVAILABLE
telephony= LINE.*_8 RES IN USE= LINE.*_8 RES AVAILABLE
ntdll=_15 RES IN USE=_15 RES AVAILABLE
database=_4 RES IN USE=_4 RES AVAILABLE
soap=_50 RES IN USE=_50 RES AVAILABLE=10
第三部分:资源监控(agent.bat或者其它例如soap.bat,代码都一样) | @echo off &color 0a | | title %~n0 | | set /a "t=10" | | :ds | | type "%computername%_%~n0.txt" | | ping localhost -n %t% >nul 2>nul | | cls &goto :dsCOPY |
|