query_wmi
A crate to query WMI
classes in windows
https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page
Windows Management Instrumentation (WMI) is the infrastructure for management data and operations on Windows-based operating systems. You can write WMI scripts or applications to automate administrative tasks on remote computers, but WMI also supplies management data to other parts of the operating system and products—for example, System Center Operations Manager (formerly Microsoft Operations Manager (MOM)), or Windows Remote Management (
WinRM
). Usage:
use ;
use ;
use get_Win32_OperatingSystem;
Return type
type Query = Vec<HashMap<String, Variant>>
.
String
is the name of the returned struct field with Variant
being an enum type.
Currently included queries:
The subsections were defined according to WMI Tasks for Scripts and Applications, you can find more classes here.
- Win32_CDROMDrive
- Win32_ComputerSystem
- Win32_PCMCIAController
- Win32_PnPEntity
- Win32_PointingDevice
- Win32_Processor
- Win32_SystemEnclosure
- Win32_USBHub
- Win32_TapeDrive
- Win32_DiskQuota
- Win32_VolumeChangeEvent
- Win32_LogicalDisk
- Win32_MappedLogicalDisk
- Win32_Volume
- Win32_DiskDrive
- Win32_DiskPartition
Building your own class queries
You can use the provided wmi
macro to make your own queries:
use wmi;
use Query;
use paste;
use HashMap;
use COMLibrary;
use ;
// this creates the function `get_CLASS_NAME()`
wmi!
// calling it
let com_con = new ?;
dbg!;
Building your own queries
You can also replace CLASS_NAME
with a query like CLASS_NAME where SOME_CONDITION=VALUE
See WQL Operators