Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a VB.NET Expert!

Join 415,729 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,844 people online right now.Registration is fast and FREE... Join Now!



Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

VB.Net : Find all IPs on a LAN How do i get the IPs of all computers on a network? Rate Topic: -----

#1 Mathieu  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-February 07


Dream Kudos: 0

Share |

VB.Net : Find all IPs on a LAN

Posted 28 February 2007 - 11:22 AM

Hi,

I've been trying to get the IPs (or computer names) of the computers in the same network as the computer running the program.

I got as far as getting all the IPs of the servers in the network wich ended up in a dead end since its all the computers that i need and not the servers only.

My goal is to get acces to files on all the other computers, i guess a shared folder would do the work and just access it as a regular folder, but for that i need the computer name (wich i can get through his IP)


Basicly, I need to find the ips of all computers in the same network wich is not what i get right now...

		   Dim localIP() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName)
			Dim strLocalIP As String = localIP(0).ToString
			Dim DomainHostEntry As System.Net.IPHostEntry
			DomainHostEntry = System.Net.Dns.GetHostEntry("workgroup")

			DomainAdressList = DomainHostEntry.AddressList



Thanks for the Help

- Mathieu

This post has been edited by Mathieu: 28 February 2007 - 11:35 AM

Was This Post Helpful? 0
  • +
  • -

#5 whisla13  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 22-May 07


Dream Kudos: 0

Re: VB.Net : Find all IPs on a LAN

Posted 22 May 2007 - 10:20 AM

Try obtaining the standard output from executing "net view". This will give you all discovered computer names (in the same workgroup) on the network.

A more advanced way would be to calculate the IP address ranges of the network based on the computer's subnet mask and IP. For example, if the computer's subnet mask is 255.255.255.0, and the computer's IP is 192.168.1.52, you can calculate from the subnet mask that valid IP address ranges on this network is 192.168.1.1 to 192.168.1.254, therefore giving you 254 addresses you can send an ICMP ECHO packet to (ping), and if you get a response packet back, then you have discovered a computer on the network. If using Framework 2.0, you can use My.Computer.Network.Ping.

- Andrew
Was This Post Helpful? 1

#6 matoksoz  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-June 07


Dream Kudos: 0

Re: VB.Net : Find all IPs on a LAN

Posted 17 June 2007 - 02:58 PM

here is my c# code

Process netsend = new Process();
netsend.StartInfo.FileName = "net.exe";
netsend.StartInfo.CreateNoWindow = true;
netsend.StartInfo.Arguments = "view";
netsend.StartInfo.RedirectStandardOutput = true;
netsend.StartInfo.UseShellExecute = false;
netsend.StartInfo.RedirectStandardError = true;
netsend.Start();


StreamReader sr = new StreamReader(netsend.StandardOutput.BaseStream, netsend.StandardOutput.CurrentEncoding);

string sss = "";
while ((sss = sr.ReadLine()) != null)
{
if (sss.StartsWith("\\"))
comboBox1.Items.Add(sss.Substring(2).Substring(0, sss.Substring(2).IndexOf(" ")).ToUpper();
}

sr.Close();
netsend.WaitForExit(1000);

string dom = Dns.GetHostName().ToUpper();
dom = dom + "\\SQLEXPRESS";
if (!comboBox1.Items.Contains(dom))
comboBox1.Items.Add(dom);

I hope this helps you
Mehmet Altan Toksöz
Was This Post Helpful? 0
  • +
  • -

#7 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • Icon

Reputation: 1398
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07


Dream Kudos: 12950

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: VB.Net : Find all IPs on a LAN

Posted 26 July 2007 - 06:24 AM

You can use this function as well.
Make sure to have this at the top of your class
Imports System.Net



Public Shared Function GetAllIP(Optional ByVal args As String() = Nothing) As Integer

		Dim strHostName As New String("")
		If args.Length = 0 Then
			' Getting Ip address of local machine...
			' First get the host name of local machine.
			strHostName = DNS.GetHostName()
			Console.WriteLine("Local Machine's Host Name: " + strHostName)
		Else
			strHostName = args(0)
		End If

		' Then using host name, get the IP address list..
		Dim ipEntry As IPHostEntry = DNS.GetHostByName(strHostName)
		Dim addr As IPAddress() = ipEntry.AddressList

		Dim i As Integer = 0
		While i < addr.Length
			Console.WriteLine("IP Address {0}: {1} ", i, addr(i).ToString())
			System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
		End While
		Return 0
	End Function



The args parameter is optional, if you pass it nothing it will retrieve the host name of the comp-uter you're on, then loop and get all IP's for that hostname. You must have a reference to System.Net.DLL in your reference list to make this work.
Was This Post Helpful? 1

#8 motcom  Icon User is offline

  • Dune Rider
  • Icon

Reputation: 213
  • View blog
  • Posts: 1,126
  • Joined: 16-June 08


Dream Kudos: 300

Re: VB.Net : Find all IPs on a LAN

Posted 03 June 2010 - 07:06 AM

A 3 year old post gets resurrected by "Hi"...
Was This Post Helpful? 0
  • +
  • -

#9 dbasnett  Icon User is offline

  • D.I.C Regular
  • PipPipPip

Reputation: 23
  • View blog
  • Posts: 266
  • Joined: 01-October 08


Dream Kudos: 0

Re: VB.Net : Find all IPs on a LAN

Posted 03 June 2010 - 11:35 AM

Why?
Was This Post Helpful? 0
  • +
  • -

#10 Guest_jay_s12*


Reputation:

Re: VB.Net : Find all IPs on a LAN

Posted 04 August 2010 - 10:22 PM

All Ip Address List on LAN That are Available.Try this guys,but change the ip in Code as u want.

Dim oWMI = GetObject("winmgmts:")
Dim IP = GetObject("winmgmts:")
Dim oPings = GetObject("winmgmts:")
Dim PcName = GetObject("winmgmts:")


For i = 100 To 101
IP = "192.168.1." + i.ToString
oPings = oWMI.ExecQuery("Select * from WIN32_Pingstatus where address='" + IP + "'" + " and ResponseTime > 0")

For Each oPing In oPings
PcName = System.Net.Dns.GetHostEntry(IP)
txtlistofhost.Text &= IP & Chr(9) & PcName.HostName & vbNewLine
Next

Next
Was This Post Helpful? 0

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users