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

Cool Tech

Toys for Boys

Family Friendly

Stocking Stuffer

SmartLens - Clip on Phone Camera Lens Set of 3

Learn more >

Christmas Gift Guide

Click for more ›

Brand Post

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

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!

Cathy Giles

Brother MFC-L8900CDW

The Brother MFC-L8900CDW is an absolute stand out. I struggle to fault it.

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?