S
Steve Long
Hello,
can someone help me figure out how to do a couple of things here? I would
like to use the Uninstall method of the Win32_Product class and am having
trouble figuring this one out.
When I do a query with the following code, I get a ManagementException of
Invalid class:
ManagementScope ms = new ManagementScope(@"root\cimv2");
SelectQuery q = new SelectQuery("SELECT * From Win32_Product where
InstallState = 5");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms, q);
ManagementObjectCollection queryCollection = query.Get();
// this line is where I'm getting the exception
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine("Name: " + mo["Name"].ToString());
// how do I invoke the Uninstall method here (given my condition is met
of course)?
}
P.S. sorry if this is totally hosed code and I appreciate any help on it.
Thanks
Steve
can someone help me figure out how to do a couple of things here? I would
like to use the Uninstall method of the Win32_Product class and am having
trouble figuring this one out.
When I do a query with the following code, I get a ManagementException of
Invalid class:
ManagementScope ms = new ManagementScope(@"root\cimv2");
SelectQuery q = new SelectQuery("SELECT * From Win32_Product where
InstallState = 5");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms, q);
ManagementObjectCollection queryCollection = query.Get();
// this line is where I'm getting the exception
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine("Name: " + mo["Name"].ToString());
// how do I invoke the Uninstall method here (given my condition is met
of course)?
}
P.S. sorry if this is totally hosed code and I appreciate any help on it.
Thanks
Steve