How to find out the difference between workstations and servers on the network?

I know how to get machines on a server using the System.DirectoryServices network. The problem is that I would like to ignore workstations / computers on the network and only get servers.

In case someone says to check the OS version, the problem with getting the version number of the Windows NT family operating system is that each number can correspond to both server and non-server OS (for example, version NT 6.1, referenced as on Win 7 and Win Server 2008 R2).

Here is my base test class:

namespace Project1
{
    class Class1
    {
        public static void Main(string[] args)
        {
             List<string> list = Class1.GetComputersOnNetwork();           
        }

        public static List<string> GetComputersOnNetwork()
        {
            string fileName = "networkcomputers.txt";  

            // Delete the file if it exists.
            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            // Create the file.
            System.IO.FileStream fs = System.IO.File.Create(fileName, 1024);

            StreamWriter strwr = new StreamWriter(fs);

            int i = 0;
            List<string> list = new List<string>();
            DirectoryEntry root = new DirectoryEntry("WinNT:");           
            foreach (DirectoryEntry computers in root.Children)
            {                   
                if ((computers.Name != "Schema"))
                {
                    i++;
                    Console.WriteLine("Machine Number " + i + ": " + computers.Name);
                    strwr.WriteLine("Machine Number " + i + ": " + computers.Name);
                    list.Add(computers.Name);
                }           
            }
            return list;
        }
    }
}
+5
source share
2 answers

operatingSystemVersion operatingSystem. SKU. , , - IsServer boolean. , , operatingSystemVersion, operatingSystemVersion, "".

+3

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallationType.

:

  • "", Windows Server (, Windows Server 2012).
  • "", Windows Desktop (, Windows 8.1).

, #.

. " ".

, archive.org: https://web.archive.org/web/20140502101009/http://blogs.msdn.com/b/ejarvi/archive/2004/06/08/151162.aspx

:

ejarvi 8 2004 15:47 9 , . , XP SP1 XP SP2 - kludge, spcheck reskit. , , ver cmd, Windows 2000 Professional Server. , . - , , ( HKLM):

\Microsoft\Windows NT\CurrentVersion\ProductName (Microsoft Windows Server 2003, Microsoft Windows XP, Microsoft Windows 2000)

\Microsoft\Windows NT\CurrentVersion\CDSVersion ( 1, 2,...)

Pro Server Windows 2000: SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType (WinNT, ServerNT)

, , DtWinVer http://www.codeproject.com/system/dtwinver.asp .

+2

All Articles