How to list installed features of Windows Server 2008 in c#

百般思念 提交于 2019-12-29 08:05:09

问题


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 ?


回答1:


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;

}


来源:https://stackoverflow.com/questions/7038901/how-to-list-installed-features-of-windows-server-2008-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!