【问题标题】:Trying to check the friendly OS name of a different workstation尝试检查不同工作站的友好操作系统名称
【发布时间】:2018-10-31 21:58:35
【问题描述】:

我正在尝试查找与我的工作站不同的工作站的友好操作系统名称。这发生在我使用时:

var name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
                        select x.GetPropertyValue("Caption")).FirstOrDefault();

它正在返回我的工作站的操作系统名称。你能建议我一个更好的方法来找出答案。

提前致谢!!

【问题讨论】:

  • this example。请注意,您必须提供另一台计算机的名称(WMI 格式)以及访问它所需的凭据。

标签: c# operating-system


【解决方案1】:

您可以使用 System.DirectoryServices 搜索目录“Wi​​nNT”,您可以在此处阅读更多信息:

https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.directoryentry.path?view=netframework-4.7.2

示例解决方案 - 将名称添加到列表中

// create list to add the names to
var pcnames = new List<string>();
// establish the domains in the local network
var directory = new DirectoryEntry("WinNT:");
// iterate through the children
foreach (DirectoryEntry workstation in directory.Children)
{
  pcnames.Add(workstation.Name)
}

【讨论】:

    猜你喜欢
    • 2010-10-09
    • 2011-09-13
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    相关资源
    最近更新 更多