如何获得远程计算机操作系统版本在.NET中,没有WMI?如何获得、操作系统、版本、计算机

2023-09-03 13:48:54 作者:你好、陌生人

有没有办法让在.net(C#)远程计算机的操作系统版本? 使用WMI是不能接受我。

Is there any way to get OS version of remote machine in .Net(C#)? Using of WMI is not acceptable for me.

我有远程计算机的IP地址:)和管理员凭据

I have IP address of remote machine :) and administrator credentials

推荐答案

根据一些usings sgmoore答案

based on sgmoore answer with some usings

    public string GetOsVersion(string ipAddress)
    {
        using (var reg = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, ipAddress))
        using (var key = reg.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\"))
        {
            return string.Format("Name:{0}, Version:{1}", key.GetValue("ProductName"), key.GetValue("CurrentVersion"));
        }
    }
 
精彩推荐
图片推荐