![Solución](https://rvso.com/image/1395286/Soluci%C3%B3n.png)
Usando netstat -a -o -n
puedo obtener la lista de puertos y PID.
luego necesito ir al administrador de tareas, agregar el PID y ver quién es. (bastante frustrante)
Me preguntaba si hay un comando CMD que lo haga todo ( usando find
,, for
)powershell
para poder obtener el nombre del proceso
Respuesta1
Solución
Utilice el -b
parámetro:
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host
multiple independent components, and in these cases the
sequence of components involved in creating the connection
or listening port is displayed. In this case the executable
name is in [] at the bottom, on top is the component it called,
and so forth until TCP/IP was reached. Note that this option
can be time-consuming and will fail unless you have sufficient
permissions.
NotaEl netstat -b
comando fallará a menos que se ejecute desde un símbolo del sistema elevado.
Solución alterna
Filtra la lista de procesos y encuentra el PID que te interesa:
tasklist | findstr /c:"PID"
Solución alternativa
Puedes usar Tcpvcon.exe
en su lugar. No se requieren derechos de administrador.
tcpvconEl uso es similar al de la utilidad integrada de Windows
netstat
.
Usage: tcpvcon [-a] [-c] [-n] [process name or PID]
-a Show all endpoints (default is to show established TCP connections).
-c Print output as CSV.
-n Don't resolve addresses.
Respuesta2
creo que estas buscandoTCPVerde SysInternals.
Respuesta3
Aquí hay un ejemplo para Windows que usa FOR
para analizar netstat
la salida y luego DO
tasklist
con /fi
un filtro en pid para mostrar el nombre del proceso.
El último hallazgo es eliminar tasklist
los encabezados.
FOR /F "usebackq tokens=5 delims= " %i IN (`netstat -ano ^|find "443"`) DO @tasklist /fi "pid eq %i" | find "%i"
imprime registros de salida como
tomcat8.exe.x64 4240 Services 0 931,864 K
Se pueden agregar campos adicionales netstat
agregando tokens.
Respuesta4
Intenta usar esto...
Nombre del proceso con marca de tiempo :) en oneliner... no es necesario realizar secuencias de comandos de forma rápida y sencilla...
Puede cambiar el parámetro SYN_SENT mediante ESTABLECIDO o ESCUCHANDO
filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern LISTENING|timestamp
filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern SYN_SENT|timestamp