How do I get all the Computer names (or details) on a local network or on the same workgroup via C#? I've Googled all over the place and have found nothing that works! Thanks in advance!
This is the one of the ways you can try to find list of computers .... in a managed code .. there are other ways also ... pls google/bing with correct keywords ...
public List<String> ListNetworkComputers()
List<String> _ComputerNames = new List<String>();
System.DirectoryServices.DirectoryEntry _WinNTDirectoryEntries = new System.DirectoryServices.DirectoryEntry("WinNT:");
foreach (System.DirectoryServices.DirectoryEntry _AvailDomains in _WinNTDirectoryEntries.Children)
foreach (System.DirectoryServices.DirectoryEntry _PCNameEntry in _AvailDomains.Children)
@xgamer: hey, I've found a lot of entries similar to what you've just given me, but none of them return anything. What I assume is, is that for this code to work, I need a domain set up, but I'm trying to get the computer names in a normal workgroup.
I've tried your code * well, but no luck.
Hey, I got it working, was very close to your example:
ArrayList nets = new ArrayList();
entryPC = new DirectoryEntry();
entryPC.Path = "WinNT://domainName";
foreach (DirectoryEntry child in entryPC.Children)
if (child.Name != "Schema")
(obviously using System.DirectoryServices)
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.