`
yanzilee9292
  • 浏览: 528164 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

WMI(windows Management Instrument)架构

 
阅读更多

编程获取或者写入操作系统的信息, 只需要关注WMI consumers这一层.  通过C/C++之外的语言, 就仅仅考虑 COM API for WMI or the Scripting API for WMI 这两种方式的第二种. 

 

Example: 通过ruby获取操作系统的版本信息, 采用Scripting API for WMI 这种方式

 

WIN32OLE.connect('winmgmts:\\\\.').ExecQuery("select * from Win32_OperatingSystem" ).each do |m| 
p "#{m.Caption} SP#{m.ServicePackMajorVersion}" 
end 
 

 

 

WMI provides a uniform interface for any local or remote applications or scripts that obtain management data from a computer system, a network, or an enterprise. The uniform interface is designed such that WMI client applications and scripts do not have to call a wide variety of operating system application programming interfaces (APIs). Many APIs cannot be called by automation clients like scripts or Visual Basic applications. Other APIs do not make calls to remote computers.

To obtain data from WMI, write a client script or application that accesses WMI Classes or provide data to WMI by writing a WMI provider. For more information, see Using WMI.

 

 

 

 

 

The following list describes the key WMI components:

  • Managed objects and WMI providers

    A WMI provider is a COM object that monitors one or more managed objects for WMI. A managed object is a logical or physical enterprise component, such as a hard disk drive, network adapter, database system, operating system, process, or service.

    Similar to a driver, a provider supplies WMI with data from a managed object and handles messages from WMI to the managed object. WMI providers consist of a DLL file and a Managed Object Format (MOF) file that defines the classes for which the provider returns data and performs operations. Providers, like WMI C++ applications, use the COM API for WMI. For more information, see Providing Data to WMI.

    An example of a provider is the preinstalled Registry provider, which accesses data in the system registry. The Registry provider has one WMI classStdRegProv, with many methods but no properties. Other preinstalled providers, such as the Win32 provider, usually have classes with many properties but few methods, such as Win32_Process or Win32_LogicalDisk. The Registry provider DLL file, Stdprov.dll, contains the code that dynamically returns data when requested by client scripts or applications.

    WMI MOF and DLL files are located in %WINDIR%\System32\Wbem, along with the WMI Command-Line Tools, such as Winmgmt.exe and Mofcomp.exe. Provider classes, such as Win32_LogicalDisk, are defined in MOF files, and then compiled into the WMI repository at system startup.

  • WMI infrastructure

    The WMI infrastructure is a Microsoft Windows operating system component. The WMI infrastructure has two components: the WMI service (winmgmt), including the WMI Core, and the WMI repository.

    The WMI repository is organized by WMI namespaces. The WMI service creates some namespaces such as root\default, root\cimv2, and root\subscription at system startup and preinstalls a default set of class definitions, including the Win32 Classes, the WMI System Classes, and others. The remaining namespaces found on your system are created by providers for other parts of the operating system or products. For more information and a list of WMI providers found in most operating system versions, see WMI Providers.

    The WMI service acts as an intermediary between the providers, management applications, and the WMI repository. Only static data about objects is stored in the repository, such as the classes defined by providers. WMI obtains most data dynamically from the provider when a client requests it. You also can set up subscriptions to receive event notifications from a provider. For more information, seeMonitoring Events.

  • WMI consumers

    A WMI consumer is a management application or script that interacts with the WMI infrastructure. A management application can query, enumerate data, run provider methods, or subscribe to events by calling either the COM API for WMI or the Scripting API for WMI. The only data or actions available for a managed object, such as a disk drive or a service, are those that a provider supplies.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics