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

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

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?