Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::" "
- ::displays the active "ESTABLISHED" connections on screen, details include: "from" adress, "to" adress, application PID and imagename,meaning application name
- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1 delims=:" %%a in (%~nx0) do set "tab=%%~a"&goto escapeloop
- :escapeloop
- if "%1"=="/?" call :help
- if "%1"=="??" call :help
- if "%1"=="-h" call :help
- if "%1"=="help" call :help
- if "%1"=="-resolve" (set switch=fo) else set switch=o
- for /f "skip=4 tokens=2,3,5" %%a in ('netstat -%switch%') do (
- set "tab1=!tab!"
- set "tab2=!tab!"
- set "tab3=!tab!"
- call :strlen ans %%a
- if "!ans!" LSS "16" (set "tab1=!tab!!tab!")
- call :strlen ans %%b
- if "!ans!" LSS "40" set "tab2=!tab!!tab!"
- if "!ans!" LSS "32" (set "tab2=!tab!!tab!!tab!")
- if "!ans!" LSS "24" (set "tab2=!tab!!tab!!tab!!tab!")
- if "!ans!" LSS "16" (set "tab2=!tab!!tab!!tab!!tab!!tab!")
- call :strlen ans %%c
- if "!ans!" LSS "3" (set "tab3=!tab!!tab!")
- set/p "=%%a!tab1!-->!tab!%%b!tab2!-->!tab!PID: %%c!tab3!--> "<nul
- for /f "tokens=1,2" %%1 in ('tasklist') do if "%%2"=="%%c" set/p "=%%1"<nul
- if "%%c"=="0" set/p "=System Idle Process"<nul
- echo.
- )
- exit/b
- :help
- echo.
- echo switches /? -h /? ?? and help will all display this message
- echo.
- echo switch -resolve does:
- echo.
- echo Displays Fully Qualified Domain Names (FQDN) for foreign
- echo addresses.
- exit/b
- :strlen
- set l=0
- set "s=%~2#"
- for %%P in (512 256 128 64 32 16 8 4 2 1) do (
- if not "!s:~%%P,1!"=="" (
- set/a "l+=%%P"
- set "s=!s:~%%P!"
- )
- )
- set "%~1=%l%"
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement