WMI Programming with Visual Basic.NET: Breaking the Ice
(Page 1 of 4 )
The goal of this series is to introduce Microsoft Windows Management Instrumentation (WMI) and get you up and running as quickly as possible, using it to manage your system through the WMI programming using .NET. In this article, we will cover the basics of WMI and how to access WMI information from Visual Basic.NET (both locally and remotely). Before diving into further details, we first need a little background in what WMI is, how it came about, and why it is valuable.
You can download a zip file of the entire Visual Studio.NET solution (developed for this article)
here.
Introduction to WMI
Windows Management Instrumentation (WMI) is the Microsoft implementation of Web-based Enterprise Management (WBEM), an industry initiative to establish standards for accessing and sharing management information over an enterprise network. WMI is WBEM-compliant and provides integrated support for the Common Information Model (CIM), the data model that describes the objects that exist in a management environment.
WMI includes a CIM-compliant object repository, which is the database of object definitions, and the CIM Object Manager, which handles the collection and manipulation of objects in the repository and gathers information from WMI providers. WMI providers act as intermediaries between WMI and components of the operating system, applications, and other systems. For example, the registry provider draws information from the registry, while the SNMP provider provides data and events from SNMP devices. Providers give information about their components, and might provide methods to manipulate the components, properties that can be set, or events that can alert you to changes in the components.
The two paragraphs above are the definitions of WMI from Microsoft WMI team. But to put it simply, you can almost manage (or administrate) a single computer, an entire network, or even several domains with just WMI. The information you get from WMI can be further integrated with databases or the Web in an enterprise to work very efficiently, or remotely. To get the information from WMI, we need to use scripting (such as VBScript or Jscript) together with a huge repository of CIM. CIM contains all classes, objects or namespaces to the related resources (such as network, printer, and so forth).
Experts even suggest diverting to WMI rather than working on core WIN32 API. It is more difficult for a beginner to understand and work with WIN32 API than WMI. You can use WMI with programming (including .NET) or scripting systems (such as Windows Script Host) to retrieve configuration details about most aspects of your computer systems, including server applications, to make changes to your systems or even to schedule the scripts. We can also remotely administer the systems available in the network using WMI. And another wonder is that several tools from Microsoft are developed using WMI as the main technology. These tools include Microsoft Systems Management Server, Microsoft Operations Manager, and others.
What all of this means is that WMI makes Windows 2000/2003 extremely manageable by using a single consistent, standards-based, extensible and object-oriented interface. Also, any application or script accessing WMI data can do so on the local machine or remotely in a seamless way. And, it's not only for Windows 2000/2003; WMI is available for Windows 95, Windows 98, and Windows NT 4.0 as well (with a separate free download).
The above paragraphs just gave only a very basic introduction to WMI. Since this article (and series) mainly focuses on accessing WMI by using .NET, I request the readers to go through MSDN and WMI SDK for a complete architecture and explanation of how to use WMI.
Next: Our first program to connect to WMI (on a local computer) >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee