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
|
| Author: kichenakoumar 09 Mar 2005 | Member Level: Bronze Points : 0 |
Improve this artcle by giving diffrent windows query's like finding the FilePath and other hardware information through wmi
|