473,698 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on WMI and System.Manageme nt class

Hello,

The code below enumerates all products installed on any given machine.
Through System.Manageme nt i can also find WMI methods that could be
exected. But i have not worked on WMI and System.Manageme nt before, i
need to know how to execute the those mehtods
ConnectionOptio ns options = new ConnectionOptio ns();
options.Authori ty = "NTLMDOMAIN:DOM AIN_X";
options.Usernam e = "xyz";
options.Passwor d = "xyz123";
string Machine = "abc";

ManagementScope scope = new ManagementScope ("\\\\" + Machine +
"\\root\\CIMv2" , options);
scope.Connect() ;

//Query system for all Installed products information
ObjectQuery query = new ObjectQuery("SE LECT * FROM Win32_Product") ;
ManagementObjec tSearcher searcher = new ManagementObjec tSearcher(scope ,
query);

// Call Get() to retrieve the collection of objects and loop through it
textBoxPrinters .Text = textBoxPrinters .Text + "*** Applications on '" +
Machine + " are\r\n";
foreach (ManagementBase Object oPrinter in searcher.Get())
{
textBoxPrinters .Text = textBoxPrinters .Text +
oPrinter["Name"].ToString() + "\r\n";
}

//Get the object on which the method will be invoked
ManagementClass processClass = new ManagementClass ("Win32_Product ");

textBoxPrinters .Text = textBoxPrinters .Text + "\r\n\r\n** ** Methods
****\r\n";
foreach(MethodD ata oPrinterMethods in processClass.Me thods)
{

Diagnostics.Wri teLine(processC lass.Methods[oPrinterMethods .Name.ToString( )
}
When you execute this code it will write following line to console
output...

*** Applications on 'abc' are

Microsoft Windows Services for UNIX
Program Files
Microsoft FrontPage Client - English
Camera Window DS
Microsoft SQL Server VSS Writer
Microsoft AntiSpyware
Microsoft .NET Compact Framework 2.0
Microsoft SQL Server 2005 Mobile [ENU] Developer Tools
......

**** Methods *****

Install
Admin
Advertise
Reinstall
Upgrade
Configure
Uninstall

What i wan to know is... how do i execute the methods above??

- Thanks
Gancy

Apr 14 '06 #1
0 2304

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

Similar topics

1
5956
by: PaulThomas | last post by:
I am using VS.Net 2000 and C# trying to access the System.Management namespace in a Web Application -but- after: using System; using System.Management; I get: The type or namespace name "Management" does not exist in the class or namespace "System" How do I go about accessing the "Management" namespace... I am trying to get the Serial Number of the CPU and Operating System from examples I have found like:
4
2658
by: raffelm | last post by:
I want to include ManagementObjectSearcher class in my code. According to MSND I need to add using System.Management to my C# file. But I dont have a Management name space in system. I'm using VS.NET2003 with Framework 1.1. What namespace am I suppose to use to get the use ManagementObjectSearcher class ? Thnx Matt
44
4212
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
2
1603
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in ASP.NET I would like to add this to the Session object whilst using SQLServer as the session storage. Unfortunately, as this required the RCW class to be serializable, this won't work, and throws an exception saying you can't Serialize the Session...
1
2504
by: theintrepidfox | last post by:
Dear Group I wonder whether anyone has some information on the cause for this error? I've created a class for Win32_BIOS with mgmtclassgen Win32_BIOS /L VB, added the file to my VB.NET project and tried calling a property with the following code in a button_click event: Dim PCBios As New ROOT.CIMV2.Win32.BIOS Debug.WriteLine(PCBios.Version­)
7
6729
by: eric | last post by:
I'm writing a program in C# and found a couple of threads about how to check the status of a printer before sending it any data, to ensure that the printer is ready to print. They say to include the System.Management namespace. This is where my problem is, I have no System.Management namespace. Could anyone help me locate it or a reference to locate it?
0
1345
by: Henry | last post by:
Below is the code I am trying to use in a console application, each time I run it I get an Management error Illegal Class error. I have traced the error to the \"Win32_Process\" line, apparently the wmi path is incorrect. Tried to run the app on both xp and vista with the same error. Could someone suggest how I might correct this wmi path variable??? Thanks Henry
4
1548
by: shane | last post by:
I am trying to get values from a WMI Query in my textbox, txtResults I don't think I am understand what I need to do to move the value from the for each statement in the quary into the textbox, as the default implementation just provides for outputing information in the console. ' this wont work and when i try to replace the console writeline with some kind of txtresluts.text .,.....I either get an error or only the first set of values...
2
3523
by: nicholas08 | last post by:
I am new to programming and trying to work on a simple console app. I am making a simple Library Management system where the user/admin can manage members and item. Attaching the menu so it's clear to understand what I am saying. http://i475.photobucket.com/albums/rr116/nicholasCsharp/Untitled.jpg So far I have only looked at Item and Member Management (option 1 and 2) Few question I had: 1. In terms of the design approach I am taking. One...
2
4650
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and install it, the codes are copied to the virtual directory under Inetpub. when i try to edit the web.config file it throws an exception access is denied to web.config file. but the same project works fine if i copy the file to some other location and...
0
8673
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8601
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7716
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2327
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.