开发者

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

开发者 https://www.devze.com 2023-03-28 04:22 出处:网络
How can I list all installed features of Windows Server 2008 in c#. I tried to query dism.exe or oclist.e开发者_开发问答xe but not all versions have it. Can I use System.Management.ManagementClass to

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


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;

}
0

精彩评论

暂无评论...
验证码 换一张
取 消