Click to See Complete Forum and Search --> : computers on a network
vbud
Feb 18th, 2003, 12:18 AM
hi all,
i'm sure this could be done fairly easy in .Net but I can't figure it out, so how to use VB.Net to list all the computers on a network or domain???
All help appreciated. thanx...
vbud
Feb 18th, 2003, 07:06 AM
So no one on this....??? :confused:
Pirate
Feb 18th, 2003, 07:16 AM
will this help http://www.c-sharpcorner.com/Code/2002/Aug/ListAllComps.asp
Pirate
Feb 18th, 2003, 07:20 AM
It's C# and it's stupid way to what you want from AD.Let me check something there :cool:
Pirate
Feb 18th, 2003, 08:13 AM
Check this
http://www.codeguru.com/network/IPAddress.html
vbud
Feb 20th, 2003, 12:34 AM
Well i've already checked those 2 links before but none seems to satisfy me, the first one is in C# and the second one in C, what I need is some piece of code in VB.Net, though C# can be embedded or eveb translated into VB apps I was hoping that someone did this in VB.net. There seems to be a way using Microsoft Active Directory.. still trying.... :confused:
Alternatively, what I was planning to do is to shell a Net View command from VB and make it output in into a text file, then read that text file and retrieve the list of computers on the network, Shelling this Dos command works fine in classic VB but it seems that in .Net the command is excuted but no file is created. My sample code is:
Shell("net view >> c:\NetList.txt", AppWinStyle.Hide)
can someone help!!!
Edneeis
Feb 20th, 2003, 01:11 AM
If you set an imports and reference to DirectoryServices then this will list all computers in a domain. Note: It doesn't matter if they are actively connected at the time or not just if they are added to the Active Directory.
Dim de As New System.DirectoryServices.DirectoryEntry("WinNT://MyDomainName")
Dim d As System.DirectoryServices.DirectoryEntry
ListBox1.Items.Clear()
For Each d In de.Children
If d.SchemaClassName = "Computer" Then
ListBox1.Items.Add(d.Name)
End If
Next
vbud
Feb 20th, 2003, 02:12 AM
I tried your above example but it seems to give me only the list of users and services that the server is running, its cannot identify the computer names.... :confused:
Edneeis
Feb 20th, 2003, 02:37 AM
Are there any computers added to the active directory? (Not just connected to the network)
Are you using the Domain root not a child computer?
vbud
Feb 20th, 2003, 02:59 AM
In fact I can't figure out if the computers are added to the active directory. The domain server is an NT 4.0 server.
Also i'm running the app from a computer connected to the network of the domain server, not the root server itself. Could this possible be the problem?
Actually i'm trying to write a file distribution program that will be used by users over a network. So using sockets, and maybe directory services, I have to detect all computers connected to the network and list them. Then the user will select a set of computers and send them a file. So the computer listing part is still pending...
Edneeis
Feb 20th, 2003, 03:28 AM
Well the trouble is that NT 4.0 Server doesn't have Active Directory. You need a Windows 2000 Server or better.
So you can scratch the Active Directory/Directory Services bit. It also sounds like you need the active computers which aren't listed with Active Directory anyway.
The easiest way to do this is run some sort of custom server app that all the clients connect to and just query that.
I only have some vb6 code to list active computers on a network and I'm not sure what OS is required for it. It uses mainly API calls, but I don't have the link handy right now sorry.
vbud
Feb 20th, 2003, 04:52 AM
Well thanx anyway, i'll have a look at the possibility of using other alternatives.
Lunatic3
Feb 20th, 2003, 07:40 AM
Dim FF As File, FS As StreamWriter, St As String
St = "C:\" & CInt(Rnd() * 10000).ToString & ".bat"
While FF.Exists(St)
St = "C:\" & CInt(Rnd() * 10000).ToString & ".bat"
End While
FS = New StreamWriter(St)
FS.WriteLine("net view > C:\netview.txt")
FS.Close()
Shell(St, AppWinStyle.Hide, True)
FF.Delete(St)
Pirate
Feb 20th, 2003, 11:08 AM
Originally posted by Lunatic3
Dim FF As File, FS As StreamWriter, St As String
St = "C:\" & CInt(Rnd() * 10000).ToString & ".bat"
While FF.Exists(St)
St = "C:\" & CInt(Rnd() * 10000).ToString & ".bat"
End While
FS = New StreamWriter(St)
FS.WriteLine("net view > C:\netview.txt")
FS.Close()
Shell(St, AppWinStyle.Hide, True)
FF.Delete(St)
?????????
Lunatic3
Feb 20th, 2003, 11:23 AM
Oh:rolleyes:
I thought anyone reading the thread will understand that the code was an answer to:
Alternatively, what I was planning to do is to shell a Net View command from VB and make it output in into a text file, then read that text file and retrieve the list of computers on the network, Shelling this Dos command works fine in classic VB but it seems that in .Net the command is excuted but no file is created. My sample code is:
visual basic code:
--------------------------------------------------------------------------------
Shell("net view >> c:\NetList.txt", AppWinStyle.Hide)
--------------------------------------------------------------------------------
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.