C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Windows Management Instrumentation


Posted Date: 27 May 2004    Resource Type: Articles    Category: .NET Framework
Author: SreetharanMember Level: Gold    
Rating: 1 out of 5Points: 4



Do you know about Windows Management Instrumentation which can be programmed easily through .net supporting languages. You can get the hardware and software details of an independent system or a remote system, you can turn off or reboot a remote/own system, you can access the security features of the system, and more and more.

Ok. now we can see what is WMI. WMI is an infrastructure which provides a standard object oriented interface. we can use the underlaying APIs to access the details.

The WMI architecture contains the following things.

Provider - intermediate agent between the system and CIMOM
Consumers - system management applications
Common Interface Model(CIM) repository - object database, in which is having the management information
Common Information Model Object Manager(CIMOM) - manages the communication and access.

The easiest way to access the Windows management information is through Windows Management Querying. To get the system information we are supplied with lot of Win32_HardwareClasses. For example to get the details of the drives in the hard disk we can use the following coding.

OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & systemName & "").ExecQuery("select * from Win32_LogicalDisk")
For Each OpSys In OpSysSet
ComboBox1.Items.Add(OpSys.Caption)
Next

The GetObject method returns a set of objects, by navigating within them we can get the rest of the details. In such a way we can reboot a remote machine in the network. code is as follows.

OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" & TextBox1.Text & "").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next

that's all.

NOTE:

Imports WbemScripting

in the project references, add a reference to \winnt\system32\wbem\wbemdisp.tlb




Responses

Author: kichenakoumar    09 Mar 2005Member Level: Bronze   Points : 0
Improve this artcle by giving diffrent windows query's like finding the FilePath and other hardware information through wmi


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Determining operating system version and details
Previous Resource: Serialization in C#
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use