What is Windows Management Instrumentation (WMI)?
Posted: (EET/GMT+2)
Windows Management Instrumentation or WMI is a new way to both get information the operating system, hardware, components and software and manage it using a common interface.
For example, if you need to query system information or manage Windows components programmatically, WMI provides a unified interface. You can use both a graphical user interface, but also a command line tool WMIC.
From the command line, you can use the WMIC tool like this:
wmic os get Caption,Version wmic process list brief
These two commands return basic information about the operating system and running processes.
WMI queries can use a SQL-like syntax called WQL. For example:
wmic process where "name='notepad.exe'" get ProcessId
This retrieves the process id of Notepad if it is running.
For scripting, WMI is available through COM interfaces. Here is a short example using VBScript:
Set svc = GetObject("winmgmts:\\.\root\cimv2")
Set col = svc.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each obj In col
WScript.Echo obj.Caption & " " & obj.Version
Next