Reputation: 21
The following command let me list running process on specified port with some other options as follows:
netstat -ano | findstr 9999
TCP 127.0.0.1 0.0.0.0:0 LISTENING 26064
How would I edit the command to list only the PID?
Upvotes: 0
Views: 2090
Reputation: 1038720
Unfortunately the netstat
command doesn't have parameters allowing you to select the columns that are shown. So you might need some additional processing of the output. One way to achieve that is to use Powershell:
netstat -ano | findstr 9999 | Select-String "TCP\s+(.+)\:(.+)\s+(.+)\:(\d+)\s+(\w+)\s+(\d+)" | ForEach-Object { Write-Output $_.matches[0].Groups[6].value }
Upvotes: 1