With WMIC we can use WMI queries in batch files.
Though the C in WMIC seems to stand for Console, I prefer to interpret it as WMI for the Command line.
To start WMIC in interactive console mode, just type:
WMIC
Typing /?
in the WMIC console will give you the same on-screen help you would get
after typing:
WMIC /?
at the command prompt: a list of switches and aliases.
Since we are dealing with batch files here, I'll use the commands for Command Line Mode from now on. If you prefer the Interactive Console Mode, just skip the WMIC at the start of each command line.
Now let's try the following commands. Don't worry, GET commands won't do any harm (don't try SET yet):
WMIC BIOS
WMIC BIOS Get Manufacturer
WMIC BIOS Get Manufacturer,Name,Version /Format:csv
WMIC BIOS Get Manufacturer,Name,Version /Format:list
WMIC BIOS Get /Format:list
WMIC BIOS Get Manufacturer,Name,Version /Format:htable
You may want to redirect the latter to a HTML file to view it in a browser:
WMIC BIOS Get Manufacturer,Name,Version /Format:htable > bios.html
START "" "%CD%.\bios.html"
Need to store the properties in variables? Try this (note the commas now being "escaped" by ˆ, carets):
FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Format:list ˆ| FIND "="') DO SET BIOS%%A
SET BIOS
Try to figure out for yourself how that worked.
A hint: try the plain WMIC command, without the FIND filtering
and without the FOR loop, and see what the output looks like...
Instead of the BIOS alias, we might
just as well have used Path Win32_BIOS, it wouldn't have
made any difference.
The reason I mention this is that my
WMI Code Generator does
indeed use Path followed by the full class name.
Besides, not every class has its own WMIC alias.
To find the full class name behind an alias, use the following command:
WMIC ALIAS
alias_name Get Target [ /Format:list ]
The result will look like this:
Target=Select
* from full_class_name
or use:
WMIC
alias_name Get CreationClassName
[ /Format:list ]
The result will be one or more lines like this:
CreationClassName=full_class_name
Use WMIC's /Node:remote_computer switch to query remote computers, and use the /NameSpace:\\root\other_namespace to query classes that are not located in the default CIMV2 namespace.
There are some WMIC samples available on this site:
Except for the reboot and shutdown, these samples are all limited to Get (read) property values only.
More samples (be carefull, some of these do actually change your system configuration):
A good source for more information is the article WMIC - Take Command-line Control over WMI by Ethan Wilansky.


And Alain Lissoir's book:
Understanding WMI Scripting
which devotes an entire chapter to WMIC.
Microsoft Windows 2000 Scripting Guide
provides an excellent explanation of WQL use in its chapter
"Retrieving Managed Resources Using WMI Query Language".
To create more "selective" queries, use the WMI Query Language,
or WQL, a subset of SQL.
See this
overview of WQL.