WMIC is the command-line version of WMI that can be used in batch scripting

WMIC is the abbreviation of Windows Management Interface Command, is a simple command prompt tool that returns information about the system you are running it on. WMIC extends WMI for operation from several command-line interfaces and through batch scripts. Before WMIC, you used WMI-based applications, the WMI Scripting API, or tools such as CIM Studio to manage WMI-enabled computers. WMIC is more intuitive than WMI, in large part because of aliases. Aliases take simple commands that you enter at the command line, then act upon the WMI namespace in a predefined way, such as constructing a complex WMI Query Language (WQL) command from a simple WMIC alias Get command. The WMIC program can return useful information about your system, control running programs and generally manage just about every aspect of your PC.

Common WMIC queries

How To Find Out The Model Of Your Computer ?

In order to find out the model name of a machine using WMI, simply follow the guide below:

Go into a command prompt and Type in

>WMIC ComputerSystem GET Model

then, you will get:

Model HP Notebook

WMIC is the command-line version of WMI that can be used in batch scripting

How to Find Your Computer Name ?

>wmic computersystem get name,systemtype

output:

Name : yourcomputername

SystemType : x64-based PC

How to Find the Serial Number of your computer ?

>wmic bios get serialnumber

One more command will help you to identify the Serial Number of your Computer

>wmic csproduct get identifyingnumber

How to Find the MAC Address of Your Computer ?

>wmic nic get macaddress,description

How to Check Your Motherboard Model Number ?

>wmic baseboard get product,Manufacturer,version,serialnumber

How to check physical memory of your computer ?

>wmic COMPUTERSYSTEM get TotalPhysicalMemory

How to get all running programs and memory usage ?

>wmic process get workingsetsize,commandline

This lists the program and the memory usage

How to get partition name size and type ?

>wmic partition get name,size,type

How to get computer manufacturer ?

>WMIC COMPUTERSYSTEM GET MANUFACTURER

output : HP

How get mode version ?

>wmic computersystem get name,systemtype
0

output: Type1ProductConfigId

System Information

This program can also provide details on many other aspects of your system.

>wmic computersystem get name,systemtype
1
>wmic computersystem get name,systemtype
2
>wmic computersystem get name,systemtype
3

will list your installed software, services, running processes and Windows startup programs, for instance.

Process Management

Using WMIC you can manage your computer process like, close all the instances of a particular program. For example, if you want to shut down all FireFox windows, for instance, then the command:

>wmic computersystem get name,systemtype
4

Write WMIC output to file

WMIC is the command-line version of WMI that can be used in batch scripting

In order to do so, simply use the /output: "< filepath & name >" switch. Insert this right after the wmic, but before any other part of the command: for instance, wmic /output:"C:\output.txt" , then the output will export the output.txt file.

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 /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
8

Typing

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
9 in the WMIC console will give you the same on-screen help you would get after typing:

FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
	SET BIOS.%%A
)
SET BIOS
0

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 remove "WMIC" from the start of each command line.

WMIC commands

  • The majority of my batch files uses WMIC's
    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    1 command to read properties of the specified WMI class.
    To find out which properties are available for a specific WMI class, use a command like:

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    2

    Feel free to experiment with WMIC's

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    1 command, it won't change any setting.

  • With WMIC's
    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    4 command you can set (change) properties, unless they are read-only.
    To find out which properties are writeable for a specific WMI class, use a command like:

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    5

    Do not use WMIC's

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    4 command unless you are absolutely sure about the consequences.

  • With WMIC's
    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    7 command you can call a WMI method for the specified class.
    To find out which methods are available for a specific WMI class use a command like:

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    8

    Do not use WMIC's

    FOR /F "tokens=*" %%A IN ('WMIC BIOS Get Manufacturerˆ,Nameˆ,Version /Value ˆ| FIND "="') DO (
    	SET BIOS.%%A
    )
    SET BIOS
    7 command unless you are absolutely sure about the consequences.

Now let's try the following commands:

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 save the latter to a HTML file to view it in a browser:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"

Need the result pasted in another window?

Use

WMIC Path Win32_NetworkAdapter Get
0

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 /Value ˆ| 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

WMIC Path Win32_NetworkAdapter Get
1 filtering and without the
WMIC Path Win32_NetworkAdapter Get
2 loops, and see what the output looks like...
Now prepend each of those lines with
WMIC Path Win32_NetworkAdapter Get
3

Narrowing down the returned selection with WHERE

Often WMI queries return far too much information, so we want to narrow down the selection.
For example, the following query against my own computer returns 27 instances, even though it has only one network adapter:

WMIC Path Win32_NetworkAdapter Get
Note:If all you want to know is the number of adapters, just list the indexes only:

WMIC Path Win32_NetworkAdapter Get
4

WQL to the rescue!

WQL or WMI Query Language allows us to get only those instances matching the conditions set by a

WMIC Path Win32_NetworkAdapter Get
5 clause.
The following modified query returns only 2 instances on my computer (it turns out the BlueTooth dongle is also considered a physical network adapter):

WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get

This is pretty straightforward.
Now list only adapters manufactured by Realtek.
The following command will not work:

WMIC Path Win32_NetworkAdapter Where "Manufacturer=Realtek" Get

WMIC Path Win32_NetworkAdapter Get
6 in this case is a string, so we need to place it in quotes, preferably without confusing them with the quotes for the entire
WMIC Path Win32_NetworkAdapter Get
5 clause.
The following commands will work:

WMIC Path Win32_NetworkAdapter Where "Manufacturer='Realtek'" Get
WMIC Path Win32_NetworkAdapter Where (Manufacturer='Realtek') Get
WMIC Path Win32_NetworkAdapter Where (Manufacturer="Realtek") Get
WMIC Path Win32_NetworkAdapter Where "Manufacturer = 'Realtek'" Get

etcetera.

Parentheses are required for more complex

WMIC Path Win32_NetworkAdapter Get
5 clauses:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
0

However, these parenthesis tend to break your

WMIC Path Win32_NetworkAdapter Get
9 loops...

A limitation of the

WMIC Path Win32_NetworkAdapter Get
5 clause is that it cannot select properties of type array.

Take a good look at WQL if you intend to use

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
8 seriously.

A note on aliases

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 /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
1

The result will look like this:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
2

or use:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
3

The result will be one or more lines like this:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
4

To list all available aliases, try this short batch file:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
5

Or use WMIAlias.bat, which can either list all aliases and their class names, or return the class for a single specified alias.

I have not yet found a way to make WMIC list all WMI classes available, but the following code comes close:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
6

The first line extracts a list of aliases from WMIC's help screen, and these aliases are "fed" to the second WMIC command line which retrieves the Target class, as discussed above.
Unfortunately, not all WMI classes have an alias, so some (most) will not be included in the list.

The resulting list is not sorted and may contain duplicates.
ListWMIClasses.bat extends the code above to display a sorted list without duplicates.

By far the easiest and most reliable way to find all WMI classes available is to use Microsoft's ScriptOMatic or my own WMI Code Generator, both with GUI, or ListWMIClasses.vbs.

Other computers & other WMI namespaces

Use WMIC's

WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get
2 switch to query remote computers.

Use WMIC's

WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get
3 switch to query classes that are not located in the default CIMV2 namespace.

Work with the registry

It is possible to use WMIC to read, write or delete registry keys and values, but I would not recommend it, it is not for the faint of heart.
REG.EXE is a lot easier to use.

The reason I still mention this feature of WMIC is the possibility to check if the current user has permissions to access a registry key or value:

WMIC /Output:bios.html BIOS Get Manufacturer,Name,Version /Format:htable
START "" "%CD%.\bios.html"
7

This code will return "errorlevel" 0 ("true") if the current user has permission to set values in

WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get
4 or 2 ("false") if not.

To combine permissions, add their associated hexadecimal numbers.

Note:You don't have to use environment variables to store the hexadecimal values:
WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get
5
will work just fine.

Samples

There are some WMIC samples available on this site:

  • BattStat.bat, which displays the battery status.
  • BootDisk.bat, which displays the boot disk, partition and drive letter.
  • CheckRegAccess.bat, which checks if the current user has the specified permissions on the specified registry key.
  • CPULoad.bat, which displays the CPU load percentage.
  • DiskSpc.bat, which displays a disk space summary for every partition on a WMI enabled computer, or a list of computers.
  • Hardware.bat, which displays a hardware summary for any WMI enabled computer.
  • is6432os.bat, which detects if the OS is 32-bit or 64-bit.
  • MdmCmds.bat, which displays the available configuration commands for your modem(s).
  • NICSpeed.bat, which displays the active Ethernet network adapters' link speed.
  • PausePrinting.bat and ResumePrinting.bat, two batch files to pause and resume printing on a specified printer.
  • Printing.bat, a batch file that combines the functionality of PausePrinting.bat and ResumePrinting.bat, and adds commands to list all printers or to flush all printjobs on the specified printer(s).
  • SortDate.bat Version 5, which displays the current date and time in YYYYMMDD and HHmmss format.
  • DatePart.cmd, which displays the specified part of the current date or time (like VBScript's
    WMIC Path Win32_NetworkAdapter Where "PhysicalAdapter=TRUE" Get
    6 function).
  • WMIC commands to reboot or shutdown any WMI enabled computer.
  • With the "Create Batch Code" button in the WMI Code Generator you can create your own WMIC samples.
    Create some samples, try them, trim and prune them until they meet your requirements.

Except for CheckRegAccess.bat, PausePrinting.bat, ResumePrinting.bat, Printing.bat, and the reboot and shutdown, these samples are all limited to Get (read) property values only.

More samples (be careful, some of these do actually change your system configuration):

More to explore:

A good source for more information is the article WMIC - Take Command-line Control over WMI by Ethan Wilansky.

Examples of WMIC commands for Windows .NET SERVER Family

Using Windows Management Instrumentation Command-line

WMIC is the command-line version of WMI that can be used in batch scripting

WMIC is the command-line version of WMI that can be used in batch scripting

And Alain Lissoir's book: Understanding WMI Scriptingwhich devotes an entire chapter to WMIC.

Microsoft Windows 2000 Scripting Guideprovides an excellent explanation of WQL use in its chapter Retrieving Managed Resources Using WMI Query Language.

Is WMIC is the command

WMIC is the command-line version of WMI that can be used in batch scripting.

What is WMIC in batch file?

Windows Management Instrumentation Command line (WMIC) WMIC operates in two modes, interactive (which allows commands to be entered one line at a time) and non-interactive (which allows commands to be scripted for use in batch files). The simplest way to launch WMIC is to open a Run dialog and type wmic.

What is WMI and WMIC?

What is WMIC? The Windows Management Instrumentation (WMI) Command-Line Utility (WMIC) is a command-line utility that allows users to perform WMI operations from a command prompt. WMI is an interface providing a variety of Windows management functions.

What does WMIC mean?

A Description of the Windows Management Instrumentation (WMI) Command-Line Utility (Wmic.exe) - Microsoft Support.