I am converting a Installer Programm from VBS into a C# programm. In this installation i have to activate some windows features with DISM.
"cmd.exe", "/C Dism /Online /Enable-Feature /FeatureName:WAS-ProcessModel"
I activated them in this way. And when i check them manualy with
dism /online /get-featureinfo /featurename:WAS-ProcessModel
in the command prompt, then i get the information of the Feature, including the Status. (Status : Activated)
But when i try to get it via my programm the Status return is just empty.
Here the relevant part of my programm:
ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2");
//create object query
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OptionalFeature Where Name=\"WAS-ProcessModel\"");
//create object searcher
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
//get a collection of WMI objects
ManagementObjectCollection queryCollection = searcher.Get();
//enumerate the collection.
foreach (ManagementObject m in queryCollection)
{
// access properties of the WMI object
Console.WriteLine("Caption : {0}" + Environment.NewLine + "Status : {1}", m["Caption"], m["Status"]);
}
The return of this is:
Caption : Prozessmodell
Status :
How can i get the status of the feature? Am i doing something completely wrong? I am new to this DISM/ WMI things so maybe it is just some basic thing i did wrong.