查找Exchange服务器的版本 [英] Find Version of Exchange server

查看:128
本文介绍了查找Exchange服务器的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在寻找一个C#/ WMI解决方案来查找机器中安装的Exchange服务器版本。



我使用了以下查询,但没有响应。

Hi All,

I am looking for a C# / WMI solution to find the version of Exchange server installed in a machine.

I have used the following query and it is not responding.

string condition = "Vendor LIKE 'Microsoft%' AND Name = 'Exchange'";
string[] selectedProperties = new string[] { "Version" };
SelectQuery query = new SelectQuery("Win32_Product", condition, selectedProperties);

using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
using (ManagementObjectCollection products = searcher.Get())
foreach (ManagementObject product in products)
{
    string version = (string)product["Version"];
       // Do something with version...
}





当我们调试代码时,执行控制就到了某个地方,当我们到达循环时,看到带下划线的代码。



有谁能帮我解决这个问题?



找到Exchange服务器版本的WMI查询是什么?

感谢你...



The execution control goes somewhere when we debug the code, exactly when we reach the loop, see the underlined code.

Can anyone help me to solve this?

What would be the WMI query to find the version of Exchange server?
Thanking You...

推荐答案

尝试包装 string version =(string)product [Version]; 在try / catch中 - 可能是某些对象没有版本 - 这可能会导致执行控制失败......
Try wrapping "string version = (string)product["Version"];" in a try/catch - could be that there are some objects that don''t have a version - and that could cause the execution control to go haywire...


这篇关于查找Exchange服务器的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆