编程获取或者写入操作系统的信息, 只需要关注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 class, StdRegProv, 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.
分享到:
相关推荐
基于 WMI(Windows Management Instrumentation)的 BIOS 接口设计 <固件 C 字营>Cstyle_x007 WMI 是 Windows 操作系统管理数据和操作的基础设施,系统管理员可以使用 VB Script、PowerShell 及 Windows API(C++、...
6: 为什么我的脚本可以在某个版本的 Windows 上运行,但在另外一个版本的 Windows 上却不能运行? 7:为什么 WMI 操作返回一个错误? 8:WMI 不工作。如何解决这个问题? 9:如何设置 WMI 命名空间的安全性? ...
这是一篇关于WMI的简明教程,Word版,相信他将有助于你的学习!
这是一个Golang 获取wmi windows硬件信息的源代码,包括CPU,网卡,内存,硬盘等信息
Windows Management Instrumentation (WMI) Remote Protocol is a Distributed Component Object Model (DCOM), as specified in [MS-DCOM], a client/server–based framework that provides an open and automated...
WMI(Windows+Management+Instruction)的介绍及应用
Elements of Windows Management Infrastructure (WMI)
chm文件类型,英文版,主要讲述用WMI工具管理Windows 的步骤及原理.适用于高级windows系统管理员.
WINdows wmi编程 C#实例 里面很清楚的介绍了好几个常见的WMI的查询
WMI简述:WMI是Windows Management Instrumentation (Windows管理工具)的缩写,是内置在 Windows 2000、Windows XP 和 Windows Server 2003 系列操作系统中核心的管理支持技术。 具体说来,WMI的本领如下: 1.获取...
使用j-Interop实现java连接wmi获取windows系统信息的例子 可以直接导入MyEclipse运行,能够获取CPU,主板,显卡,声卡,网卡,以及CPU使用率,内存使用率等
Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。 本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统 ...
WMI——Windows Management Instrumentation是WBEM的Windows实现。
WMI(Windows Management Instrumentation,Windows 管理规范)是一项核心的 Windows 管理技术;用户可以使用 WMI 管理本地和远程计算机。 WMI查询可通过WMI命令查询系统的信息,本文档演示如何使用WMI查询。
与以前的操作系统相比,Windows 2K/XP的优点之一是具有更好的可管理性。...WMI是Windows Management Instrumentation的缩写,即Windows管理规范。WMI有许多用途,其中之一就是通过脚本编程实现管理自动化
WMI in Windows PowerShell 4.0
该文件为微软提供的MicrosoftFixit50688.msi文件,可以用来解决事务日志中出现的windows事件ID10,WMI错误
wmi For windows 2003 sdk,如果你在开发需要wmi 的命名空间,但有苦于不知到方法以及属性的使用. 或者你还在使用wbemtest.exe 查询wmi 的扩展类的话,那么你该换帮助文件了. 安装本sdk 和其他sdk 一样或产生帮助文件. ...
Managing Windows with VBScript and WMI 2004.chm 共享资源,
WMI(Windows Management Instrumentation)是Windows系统后台运行的一个事件管理器,常用于检查隐匿脚步,修复篡改主页等问题。