If you want to find out which ports a process is using and you know the process name, you must first determine the process identifier (PID). For example, to identify the PID for the oracle.exe process running on my system, I went to the command promptĀ and typed
c:\> tasklist
This command returned the following information:
The second column shows the PID, which I can then use with the Netstat command to search all in-use ports. For example, if I type
c:\> netstat -ano | findstr 2140
my system returns the following information:
This result shows that the Oracle service was using TCP port 1028, 1030, 1031 on all addresses.
You can also perform a reverse operation to find out which process is associated with a port. For example, to identify which process is using port 25, I could go to the command prompt and type
c:\> netstat -ano | findstr :1030
On my system, this command returns the following information:
After I identify the process (in this case, 2500), I can determine the process name by typing
c:\> tasklist /fi "PID eq 2140"
which returns the following information on my system:
You can also use the TCPView program from http://www.sysinternals.com, which makes the whole process a lot simpler.
– SARWAN