0

I want to get a list of computers in a workgroup with IP address and host name using C#. We do have multiple computers having the same host names in workgroup. We are using below code to get list of computers in workgroup.

using (DirectoryEntry workgroup = new DirectoryEntry("WinNT://Workgroup"))
{
    foreach (DirectoryEntry childEntry in workgroup.Children)
    {
        Console.WriteLine(child.Name);
    }
}

However it only outputs one of the computers in the case of machines having multiple host names. For example, if I have four machines having the same hostnames, the above code outputs only one machine.

We tried net view command in cmd prompt. It does the same thing and shows only hostname.

Any ideas?

4

0 回答 0