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...
Printable View
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...
So no one on this....??? :confused:
will this help http://www.c-sharpcorner.com/Code/20...stAllComps.asp
It's C# and it's stupid way to what you want from AD.Let me check something there :cool:
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:
VB Code:
Shell("net view >> c:\NetList.txt", AppWinStyle.Hide)
can someone help!!!
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.
VB Code:
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
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:
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?
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...
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.
Well thanx anyway, i'll have a look at the possibility of using other alternatives.
VB Code:
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)
?????????Quote:
Originally posted by Lunatic3
VB Code:
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)
Oh:rolleyes:
I thought anyone reading the thread will understand that the code was an answer to:
Quote:
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)
--------------------------------------------------------------------------------