:: 날짜, 시간구하기
for /f “tokens=2-3 delims=/ ” %%i in (‘date/t’) do @set DT=%%i%%j
for /f “tokens=1-3 delims=: ” %%i in (‘time/t’) do @set tm=[%%i:%%j %%k]
:: 1004포트로 establish 된세션과, 5050 모든세션 (close wait포함) 구해서텍스트로임시저장
cmd /c netstat -ant | find “1004” | find /c “ESTA” > c:\esta.txt
cmd /c netstat -ant | find /c “1004” > C:\all.txt
:: 세션수임시저장한텍스트를로그형식으로저장
for /f %%s in (c:\esta.txt) do SET EST=%%s
for /f %%g in (c:\all.txt) do SET ALL=%%g
echo %tm% Est_count : %EST% >> C:\Users\Administrator\Desktop\Est_count\est_session_%DT%.txt
echo %tm% all_count : %ALL% >> C:\Users\Administrator\Desktop\Est_count\all_session_%DT%.txt
echo.