How can you find out which process is listening on a port on Windows?
相关问题
- Inheritance impossible in Windows Runtime Componen
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- RMI Threads prevent JVM from exiting after main()
- CosmosDB emulator can't start since port is al
- fsc.exe is very slow because it tries to access cr
Follow these tools :- From cmd :-
C:\> netstat -anob
with Administrator privilege.http://technet.microsoft.com/en-us/sysinternals/bb896653 - Process Explorer
http://technet.microsoft.com/en-us/sysinternals/bb896645 - Process Dump
http://technet.microsoft.com/en-us/sysinternals/bb896644 - Port Monitor
All from sysinternals.com
If you just want to know process running and threads under each process, I recommend to learn about
wmic
. Wonderful cmd line tool, which gives you much more than you can know.Exampe :-
Above command will show all process list in brief every 5 seconds. To know more, you can just go with
/?
command of windows , for E.g,and so on and so forth. :)
Using Powershell...
...this would be your friend (replace 8080 with your port number):
Sample output
So in this example tnslsnr.exe (OracleXE database) is listening on port 8080.
Quick explanation
Select-String
is used to filter the lengthy output ofnetstat
for the relevant lines.-Pattern
tests each line against a regular expression.-Context 0,1
will output 0 leading lines and 1 trailing line for each pattern match.Use TCPView if you want a GUI for this. It's the old Sysinternals app that Microsoft bought out.
Programmatically, you need stuff from iphlpapi.h, for example GetTcpTable2(). Structures like MIB_TCP6ROW2 contain the owner PID.
With PowerShell 5 on Windows 10 or Windows Server 2016, run
Get-NetTCPConnection
cmdlet. I guess that it should also work on older Windows versions.The default output of
Get-NetTCPConnection
does not include Process ID by some reason and it is a bit confusing. However, you could always get it by formatting the output. The property you are looking for isOwningProcess
.If you want to find out the ID of the process that is listening on port 443, run this command:
Format the output to a table with the properties you look for:
If you want to find out a name of the process, run this command:
You can get more information if you run the following command:
using the 'Find' command allows you to filter the results. find /i "listening" will display only ports that are 'Listening'. Note, you need the /i to ignore Case otherwise you would type find "LISTENING". |find "port" will limit the results to only those containing the specific port number. Note, on this it will also filter in results that have the port number anywhere in the response string.