/build/static/layout/Breadcrumb_cap_w.png

Getting a Process Name Using a Port...

 

Hi all,

I'm wondering how I can get the name of a process on a port. During our install I am calling the following code to see if a user entered port is open. If not, I want to get information on the process tied to the port because if let's say the name is a certain value, I'll allow the entry...

 

Dim hostname As String = "127.0.0.1" 
Dim port As Integer
Dim ipa As IPAddress = DirectCast(Dns.GetHostAddresses(hostname)(0), IPAddress) 
Dim sock As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)     'Port will have a value grabbed from the running installer (Session.Item)...  sock.Connect(ipa, port)  If sock.Connected = True Then     'Connection in use...port not available      session.Item("PORT_VALID") = "" End If sock.Close()

As is, the code runs OK for me in that if the port is in use, there is notification. I would like to do a second check to see what process is running on the selected port. If is is the process that is intended for this port, I want to allow the entry even though it is in use.

Any help is Greatly appreciated!!


0 Comments   [ + ] Show comments

Answers (1)

Posted by: jagadeish 12 years ago
Red Belt
3

Comments:
  • I was looking for VB.NET code to do it, but I may just have to call commands contained in the linked article, create text files, read the results, etc. - Superfreak3 12 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ