Win32_SoftwareFeatureParent, ROOT\cimv2, c# samples

Class | Methods | Properties (2) | Qualifiers (7) | Instances (40) | Namespaces (1)
Samples: VB Script | C# | VB.Net | Search on:Microsoft

Win32_SoftwareFeatureParent - c# code samples

WMI query - sample windows WQL with C#, Antecedent property of Win32_SoftwareFeatureParent

Get a specified instance of Win32_SoftwareFeatureParent by a key, get a default unnamed instance (singleton) of the class or list instances of the class by wmi query using this c# sample code.
See in another language: VBScript, VB.Net.
	//https://wutils.com/wmi/
	
	//Project -> Add reference -> System.Management
	//using System.Management;
	
	//create a management scope object
	ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2");
	
	//create object query
	ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_SoftwareFeatureParent Where Antecedent=\"Win32_SoftwareFeature.IdentifyingNumber=\\\"{B7E38540-E355-3503-AFD7-635B2F2F76E1}\\\",Name=\\\"VC_Redist_12222_x86_enu\\\",ProductName=\\\"Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4974\\\",Version=\\\"9.0.30729.4974\\\"\"Dependent=\"Win32_SoftwareFeature.IdentifyingNumber=\\\"{B7E38540-E355-3503-AFD7-635B2F2F76E1}\\\",Name=\\\"FT_VC_Redist_ATL_x86\\\",ProductName=\\\"Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4974\\\",Version=\\\"9.0.30729.4974\\\"\"");
	
	//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("Antecedent : {0}", m["Antecedent"]);
	  
	}
	

WMI query - list of class instances

List of all instances of Win32_SoftwareFeatureParent class in C#.
See in another language: VBScript, VB.Net.
	//https://wutils.com/wmi/
	
	//Project -> Add reference -> System.Management
	//using System.Management;
	
	//set the class name and namespace
	string NamespacePath = "\\\\.\\ROOT\\cimv2";
	string ClassName = "Win32_SoftwareFeatureParent";
	
	//Create ManagementClass
	ManagementClass oClass = new ManagementClass(NamespacePath + ":" + ClassName);
	
	//Get all instances of the class and enumerate them
	foreach (ManagementObject oObject in oClass.GetInstances())
	{
		//access a property of the Management object
		Console.WriteLine("Antecedent : {0}", oObject["Antecedent"]);
	}
	
comments powered by Disqus
WUtils.com