Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用c#,wmi检索远程计算机详细信息_C#_Asp.net_Wmi_Wmic - Fatal编程技术网

使用c#,wmi检索远程计算机详细信息

使用c#,wmi检索远程计算机详细信息,c#,asp.net,wmi,wmic,C#,Asp.net,Wmi,Wmic,我正在使用c#和wmi检索计算机详细信息。我正在使用以下代码检索信息: ManagementScope scope =new ManagementScope(@"\\"+strIPAddress+@"\root\cimv2"); SelectQuery query = new SelectQuery(); query.QueryString = "select * from Win32_OperatingSystem";

我正在使用c#和wmi检索计算机详细信息。我正在使用以下代码检索信息:

        ManagementScope scope =new ManagementScope(@"\\"+strIPAddress+@"\root\cimv2");
        SelectQuery query = new SelectQuery();
        query.QueryString = "select  * from Win32_OperatingSystem";           
        ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
        ManagementObjectCollection queryCollection = searcher.Get();
        foreach (ManagementObject m in queryCollection)
        {
         //////////////////////////////////
        }
它在windows操作系统上运行良好,但在linux或Citrix服务器上不起作用

我还尝试了以下代码:

         string strURL="http://www.google.com"; 

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
        try
        {
            HttpWebResponse response =(HttpWebResponse) request.GetResponse();
            string strServer= response.Server;           
        }
        catch (WebException wex)
        {
          // Safe cast to HttpWebResponse using 'as', will return null if unsuccessful
            var httpWebResponse = wex.Response as HttpWebResponse;
            if (httpWebResponse != null)
            {
                var httpStatusCode = httpWebResponse.StatusCode;

                // HttpStatusCode is an enum, cast it to int for its actual value
                var httpStatusCodeInt = (int)httpWebResponse.StatusCode;
            }
        }
它没有给我远程服务器os名称,而是给我IIS名称

当我在互联网上搜索时,我发现了以下网站:


任何人都可以检索信息的地方。谁能告诉我它是如何工作的,或者我们如何使用c#获取这些详细信息。

WMI是Windows管理工具。顾名思义,WMI不适用于非Windows操作系统。我误解你的问题了吗?@Nilpo,有没有像netcraft那样的脚本来获取非Windows机器的详细信息。