473,549 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help using Win32_Product.U ninstall

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
Jan 20 '06 #1
3 5593
You could also run
MSIEXEC /x package options
to uninstall, using the Process class.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steve Long" wrote:
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

Jan 20 '06 #2
Yea, we've considered that but the tech doesn't want to use that methodology
for some reason. Besides, isn't the classid going to change for different
versions?
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:15******** *************** ***********@mic rosoft.com...
You could also run
MSIEXEC /x package options
to uninstall, using the Process class.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steve Long" wrote:
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

Jan 20 '06 #3
The CLSID will change, but you should still be able to enumerate them against
application names. Just trying to look at it from another angle, since I
have no idea how to manipulate the MO to "uninstall" .
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steve Long" wrote:
Yea, we've considered that but the tech doesn't want to use that methodology
for some reason. Besides, isn't the classid going to change for different
versions?
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:15******** *************** ***********@mic rosoft.com...
You could also run
MSIEXEC /x package options
to uninstall, using the Process class.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steve Long" wrote:
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


Jan 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14586
by: Mark Hoffman | last post by:
I'm a newbie at Oracle..Be gentle! I have a table that stores information (WMI data) about computers on our network. The table looks like: ComputerID ItemID Class Property Value
5
4252
by: Leslie Lim | last post by:
I had link my 4 of workstations to server with MySql. 1 pc of my pc can run a software which can update MsSql perfectly but not others(3 failed). I tried to add System Dsn data source for Control Panel - Odbc data source 32. The pc which working fine with the software function but 3 of the rest not. My pcs running xp and win98 ! Regards....
0
1363
by: TDM | last post by:
Hello all, I suspect I created my own problem as I had a need to install an older version of MSDN Library so now my .NET Documentation is broken. When I run : Start/All Programs/Microsoft Visual Studio .NET/Microsoft Visual Studio .NET Documentation All I get is a blank IDE with this text :
4
438
by: Steve House | last post by:
I'm running VS.Net 2003 on an XP system with the most recent MSDN library integrated into it. When you do a search in the help, only "a"'s appear in the search results title column as a column 1 character wide, with nothing appearing in the rank or location columns (this is in the VS.Net window). Double clicking on any row will bring up an...
5
1198
by: Paul M. | last post by:
When I click the 'How do I ?' menu item in the C# IDE the proper screen comes up but it is empty and a message box says: Package Visual Studio Common IDE package failed to load. Then if I click on Help Favorites or Search I get the error: The operation could not be completed. No such interface is supported. I am using the latest download of C#...
1
1227
by: Isaac | last post by:
Hello, I'm trying to get this script working. Bascially, it gets a list of computers from AD, then loops through them to gather hardware informatino (which it writes to a text file). It runs fine for the first computer, echos its name then runs the WMI component. The problem is that after if echos the second computer name it it gets to...
5
9013
by: Brian Henry | last post by:
I have this script Dim query As New ManagementObjectSearcher("Select * from Select * from Win32_Product") Debug.Write(query.Get().Count) For Each mo As ManagementObject In query.Get Me.ListBox1.Items.Add(mo("Name"))
5
5147
by: esparkman | last post by:
Hey guys I am working on a application, that will pull our inventory campus wide. I'm having troubles getting it to pull our software serial numbers. It keeps throwing a Exception when it gets to that point. Below is the code I am using. If someone could give me a few ideas. The app is in Console form now to be translated to a Windows App at a...
5
3280
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
7524
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.