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 ManagementExcep tion of
Invalid class:
ManagementScope ms = new ManagementScope (@"root\cimv2") ;
SelectQuery q = new SelectQuery("SE LECT * From Win32_Product where
InstallState = 5");
ManagementObjec tSearcher query = new ManagementObjec tSearcher(ms, q);
ManagementObjec tCollection queryCollection = query.Get();
// this line is where I'm getting the exception
foreach(Managem entObject mo in queryCollection )
{
Console.WriteLi ne("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 ManagementExcep tion of
Invalid class:
ManagementScope ms = new ManagementScope (@"root\cimv2") ;
SelectQuery q = new SelectQuery("SE LECT * From Win32_Product where
InstallState = 5");
ManagementObjec tSearcher query = new ManagementObjec tSearcher(ms, q);
ManagementObjec tCollection queryCollection = query.Get();
// this line is where I'm getting the exception
foreach(Managem entObject mo in queryCollection )
{
Console.WriteLi ne("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
Comment