WMI is an industry recommendation to develop a standardized technology for accessing management information in enterprise environments. This information includes the state of system memory, a list of currently installed client applications, and other data about client status.
WMI is a scalable system management architecture that uses a unified, standards-based and extensible object-oriented interface. It provides a standard method of interacting with system administrator information and the underlying WMI API, used primarily by system management application developers and system administrators to access and operate system management information.
WMI can be used to generate tools for organizing and managing system information, allowing system administrators to monitor system activities more closely.
WMI provides a rich set of system management services built into the Microsoft Windows operating system, and is now used by a large number of applications, services and devices to provide comprehensive management capabilities for information technology operations and product support organizations. The use of WMI-based management systems brings a more reliable computing environment and higher system reliability, thus saving enterprise expenses.
The large number of specifications provided by WMI implement the following management tasks for many high-end applications, such as Microsoft Exchange, Microsoft SQL Server, and Microsoft Internet Information Services (IIS).
1. Monitor application performance
2. Detect bottlenecks or failures
3. Manage and configure applications
4. Query application data (using object-relational traversals and queries)
5. Perform seamless local or remote management operations
Below we use an example to illustrate the powerful functions of WMI. Taking vb6 as column:
Reference "Microsoft WMI Scripting V1.1 Library"
The code is as follows:
Option ExplicitDim WithEvents Sink As SWbemSinkDim j As Integer' function: Use wmi components to get computer information. Each small function is written separately for everyone to check. Private Sub cmdDone_Click()Dim oWMINameSpace As SWbemServicesDim oLogicalDiskSet As SWbemObjectSetDim oLogicalDisk As SWbemObject Dim ObjSet As VariantDim sDrive As StringDim sValue As StringDim dblSize As DoubleDim Obj As Variant Dim lIndex As Long Set oWMINameSpace = GetObject("winmgmts:") 'Get drive informationOn Error Resume NextSet ObjSet = oWMINameSpace.InstancesOf("Win32_DiskDrive") For Each Obj In ObjSet List5. AddItem Obj.Caption & " - " & BytesToMegabytes(Obj.Size) & " GB"Next 'Get detailed information of each driveOn Error GoTo ErrorHandler'Set oWMINameSpace = GetObject("winmgmts:")Set oLogicalDiskSet = oWMINameSpace.InstancesOf("Win32_LogicalDisk")For Each oLogicalDisk In oLogicalDiskSet On Error Resume Next sDrive = oLogicalDisk.deviceid ListView1.ListItems.Add , , sDrive lIndex = ListView1.ListItems.Count sValue = oLogicalDisk.Description & "" ListView1.ListItems(lIndex).SubItems(1) = sValue sValue = oLogicalDisk.FileSystem & "" ListView1.ListItems(lIndex).SubItems(2) = sValue sValue = oLogicalDisk.VolumeName & "" ListView1.ListItems(lIndex).SubItems(3) = sValue sValue = oLogicalDisk.VolumeSerialNumber & "" ListView1.ListItems(lIndex).SubItems (4) = sValue sValue = oLogicalDisk.Size & "" If IsNumeric(sValue) ThendblSize = BytesToMegabytes(CDbl(sValue))sValue = CStr(dblSize) & " MB" End If ListView1.ListItems(lIndex).SubItems(5) = sValueNext CleanUp: Set oLogicalDisk = NothingSet oLogicalDiskSet = NothingSet oWMINameSpace = NothingExit Sub ErrorHandler:MsgBox "" & Err.Description GoTo CleanUp End Sub Private Sub Command1_Click()Unload MeEnd Sub Private Function BytesToMegabytes(Bytes As Double) As Double Dim dblAns As Double dblAns = (Bytes / 1024) / 1024 BytesToMegabytes = Format(dblAns, "###,###,##0.00")End Function Private Sub Command2_Click()Dim oWMINameSpace As SWbemServicesDim SystemSet As VariantDim System As VariantDim ObjSet As VariantDim Obj As Variant Set oWMINameSpace = GetObject("winmgmts:" )'Operating System Set SystemSet = oWMINameSpace.InstancesOf("Win32_OperatingSystem") For Each System In SystemSet List1.AddItem System.Caption List1.AddItem System.Manufacturer List1.AddItem System.BuildType & "" 'It seems that List1.AddItem System.Version List1.AddItem cannot be taken out under Win9x System.SerialNumberNext'cpuSet ObjSet = oWMINameSpace.InstancesOf("Win32_Processor") For Each Obj In ObjSet List2.AddItem Obj.Caption List2.AddItem Obj.currentclockspeed & " Mhz"Next End Sub Private Sub Command3_Click()Dim oWMINameSpace As SWbemServicesDim ObjSet As VariantDim Obj As VariantDim Adapter As Variant 'Memory Set oWMINameSpace = GetObject("winmgmts:")Set ObjSet = oWMINameSpace.InstancesOf("Win32_PhysicalMemory")Dim i As String For Each Obj In ObjSet List3.AddItem BytesToMegabytes(Obj.capacity) & " MB" & " Chip"Next 'Network Card Set Sink = New SWbemSink Set Adapter = GetObject("winmgmts:")Adapter.InstancesOfAsync Sink, "Win32_NetworkAdapter" End Sub Private Sub Form_Load()j = 0End Sub Private Sub Sink_OnObjectReady(ByVal objWbemObject As WbemScripting.ISWbemObject, ByVal objWbemAsyncContext As WbemScripting.ISWbemNamedValueSet) Dim Adapter As Variant'Get all adapter information Set Adapter = GetObject("winmgmts:Win32_NetworkAdapterConfiguration=" & j & "") List4.AddItem Adapter.Description If IsNull(Adapter.MACAddress) Then List4.AddItem "No MAC Address" List4.AddItem " "Else List4.AddItem "Mac: " & Adapter.MACAddress List4.AddItem ""End If j = j + 1End SubThis article is introduced here. For more information, you can refer to this article: http://technet.microsoft.com/en-us/library/ee198932.aspx