1
votes

So I'm pretty new to WMI and I was wondering if anyone had some good books/texts to read about it, but more specifically how to correctly query WMI. I am working on a program that requires to get a lot of WMI objects and I just don't really understand the nuances in the queries and how exactly they work (note I have never worked with SQL before). Sorry if this question is weird/too broad...

An example of queries I don't really understand the difference/concept with are:

SELECT * FROM meta_class WHERE __class= 'Win32_NetworkAdapter'
SELECT * FROM Win32_NetworkAdapter

Thank you for taking your time to read this...

1

1 Answers

3
votes

WQL(and SQL) have 3 main parts(note that only SELECT and FROM are mandatory.

  • SELECT - what to select
  • FROM - from where to select
  • WHERE - filters that we cant to use( =, <=, <>(not equls), etc.)

some examples i will Win32_Process class

  1. SELECT * FROM Win32_Process => gets all the instances of a WMI class named Win32_Process
  2. Select * From Win32_Process WHERE ProcessId = 608 => same as 1 but will return Win32_Process instances with process ID equals to 608.
  3. Select * From Win32_Service Where Name > "M" And Name < "O" => returns all Win32_Service instances whose Name is greater than ‘M’ or less than ‘O’.