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:
```rust use querywmi::computerhardware::{ getWin32CDROMDrive, getWin32ComputerSystem, getWin32OperatingSystem, getWin32PCMCIAController, getWin32PnPEntity, getWin32Processor, getWin32SystemEnclosure, getWin32TapeDrive, getWin32USBHub, }; use wmi::COMLibrary;
fn main() -> Result<(), Box
type Query = Vec<HashMap<String, Variant>>
.
String
is the name of the returned struct field with Variant
being an enum type.
The subsections were defined according to WMI Tasks for Scripts and Applications, you can find more classes here.
You can use the provided wmi
macro to make your own queries:
```rust
use querywmi::wmi; use querywmi::Query; use paste::paste; use std::collections::HashMap; use querywmi::COMLibrary; use querywmi::{Variant, WMIConnection};
// this creates the function get_CLASS_NAME()
wmi! {
/// Documentation
CLASSNAME, r"pathto_namespace"
}
// calling it let comcon = COMLibrary::new() ?; dbg!(getCLASSNAME(comcon)?); ```
You can also replace CLASS_NAME
with a query like CLASS_NAME where SOME_CONDITION=VALUE
See WQL Operators