Getting started with Windows Management Instrumentation

Most people are accustomed to managing Windows XP Professional the point-and-click way. However, thanks to the Windows Management Instrumentation (WMI) technology, Microsoft’s implementation of the Web Based Enterprise Management (WBEM) standard published by the Distributed Management Task Force (www.dmtf.org), you can also use the command line to manage Windows XP Professional.

WMI allows you to manage computers locally or remotely over a network. It uses XML containers or databases, formatted according to the Common Information Model (CIM) standard schema. The files for the WBEM implementation in Windows XP Professional are in %systemroot%\System32\Wbem by default.

Working directly with WMI schemas and classes is cumbersome, so Microsoft provides the WMIC (WMI command-line) tool as an interface to them. WMIC comes with a set of built-in aliases which makes it easier to get to the WMI classes and use them for common management tasks. WMIC can be used either interactively, which puts in a shell mode with a prompt, or non-interactively for quick tasks or inclusion in scripts (see here for a screenshot).

To start up WMIC, simply open a CMD shell and type “wmic” into it. You’ll see this prompt:

wmic:root\cli

which tells you that WMIC is active, and that you’re at the top-level ‘role’ or namespace on your computer. To see which aliases are available, type /? for a full listing; each alias comes with online help, again accessible with the /? switch, like this:

wmic:root\cli>cpu /?

CPU - CPU management.

HINT: BNF for Alias usage.
(<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb clause>].

USAGE:

CPU ASSOC [<format specifier>]
CPU CREATE <assign list>
CPU DELETE
CPU GET [<property list>] [<get switches>]
CPU LIST [<list format>] [<list switches>]

If you then, for example, type cpu get /? you’ll get the full property list retrievable for that sub-command, as well as the various switches for output formatting it supports.

The CREATE and DELETE command obviously don’t do anything of the kind with the physical devices in your computer; instead, they work on the WMI classes, so be careful when using them.

Here’s an example of how to select data from the ‘get’ sub-command output:

wmic:root\cli>cpu get manufacturer, maxclockspeed, l2cachesize
L2CacheSize Manufacturer MaxClockSpeed
1024 GenuineIntel 1395


WMIC comes into its own when used for managing systems over a network. Provided security policies grant you access and Remote Procedure Calls are available, managing networked computers is as easy as:

wmic:root/cli>/node:”name_of_other_computer”

Another nice feature of WMIC is that it allows you to save the command output in TXT, HTML, XML, CSV and other formats. Here’s a quick way to create an HTML table with all the Hotfixes and updates installed on your computer listed:

C:\wmic /output:c:\qfelist\qfe.html qfe get /format:htable.xsl

Note that, currently, WMIC doesn’t handle paths with spaces in them. Use the /APPEND alias to add additional listings to the output file. You can do more than just data collection and report formatting with WMIC. This command kills a hung process, program.exe, on the computer Derek:

c:\wmic /node:”derek” process where name=”program.exe” delete

Windows XP Professional comes with a GUI tool to browse schemas on your local and remote computers: the WMI Tester program (wbemtest.exe). You can use WBEMtest to view all the 900-plus classes provided with Windows XP Professional, create and delete new ones, as well as execute methods, run queries and generally learn more about WMI. The WMI Tester comes with good documentation in a Windows Help file, which is an added bonus.

WARNING

Please note that these tips require Administrator security context for the full set of commands and, in some cases, give access to low-level configuration of your computer which, if set wrongly, could render it inoperable. Back up your system before implementing!

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Juha Saarinen

PC World
Show Comments

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Jack Jeffries

MSI GS75

As the Maserati or BMW of laptops, it would fit perfectly in the hands of a professional needing firepower under the hood, sophistication and class on the surface, and gaming prowess (sports mode if you will) in between.

Taylor Carr

MSI PS63

The MSI PS63 is an amazing laptop and I would definitely consider buying one in the future.

Christopher Low

Brother RJ-4230B

This small mobile printer is exactly what I need for invoicing and other jobs such as sending fellow tradesman details or step-by-step instructions that I can easily print off from my phone or the Web.

Aysha Strobbe

Microsoft Office 365/HP Spectre x360

Microsoft Office continues to make a student’s life that little bit easier by offering reliable, easy to use, time-saving functionality, while continuing to develop new features that further enhance what is already a formidable collection of applications

Michael Hargreaves

Microsoft Office 365/Dell XPS 15 2-in-1

I’d recommend a Dell XPS 15 2-in-1 and the new Windows 10 to anyone who needs to get serious work done (before you kick back on your couch with your favourite Netflix show.)

Maryellen Rose George

Brother PT-P750W

It’s useful for office tasks as well as pragmatic labelling of equipment and storage – just don’t get too excited and label everything in sight!

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?