473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Question on WMI and System.Management class

Hello,

The code below enumerates all products installed on any given machine.
Through System.Management i can also find WMI methods that could be
exected. But i have not worked on WMI and System.Management before, i
need to know how to execute the those mehtods
ConnectionOptions options = new ConnectionOptions();
options.Authority = "NTLMDOMAIN:DOMAIN_X";
options.Username = "xyz";
options.Password = "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("SELECT * FROM Win32_Product");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(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 (ManagementBaseObject 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(MethodData oPrinterMethods in processClass.Methods)
{

Diagnostics.WriteLine(processClass.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 2260

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

Similar topics

1
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...
4
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...
44
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...
2
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...
1
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...
7
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...
0
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...
4
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...
2
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...
2
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.