本文介绍了如何列出在C#中的Windows Server 2008安装的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何列出的C#Windows Server 2008的所有安装的功能。我试着查询 dism.exe oclist.exe 但不是所有版本都有它。我可以用 System.Management.ManagementClass 来做到这一点不知?

How can I list all installed features of Windows Server 2008 in c#. I tried to query dism.exe or oclist.exe but not all versions have it. Can I use System.Management.ManagementClass to do this somehow ?

推荐答案

我发现它,你必须使用Win32_ServerFeature类()和System.Management.ManagementClass。它适用于WS2008

I have found it, you have to use Win32_ServerFeature Class (http://msdn.microsoft.com/en-us/library/cc280268(VS.85).aspx) and System.Management.ManagementClass. It works on ws2008.

ManagementClass objMC = new ManagementClass(
            "Win32_ServerFeature");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
    string featureName = (string)objMO.Properties["Name"].Value;

}

这篇关于如何列出在C#中的Windows Server 2008安装的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 20:28