WMI Command-line

The WMI command-line (WMIC) provides you a simple command-line interface to Windows Management Instrumentation (WMI). WMIC provides a simple interface to WMI so you can take advantage of WMI to manage computers running Microsoft Windows. WMIC interoperates with existing shells and utility commands, and can be easily extended by scripts or other administration-oriented applications.

WMIC allows you to:

  • Browse the WMI schemas and query their classes and instances, usually using "aliases" that make WMI more intuitive.
  • Work with the local computer, remote computers, or multiple computers in a single command.
  • Customize aliases and output formats to suit your needs.
  • Create and execute scripts based on WMIC.

WMI Providers are available to allow WMI to manage a wide variety of hardware components, operating system subsystems, and application systems. WMIC can be used with all the schemas implemented by those WMI Providers.

WMIC can be used from any computer with WMIC enabled to remotely manage any computer with WMI. WMIC does not have to be available on the remotely managed computer in order for WMIC to manage it.

Scenarios

You can use WMIC to ease tasks in the following typical scenarios:
  • Local management of a computer—you are at the computer and use the WMIC command to manage it.
  • Remote management of a computer—you are at one computer and use WMIC to manage another computer.
  • Remote management of multiple computers—you are at on one computer and use WMIC to manage multiple computers with a single command.
  • Remote management of a computer (using a remote session)—you use a remote sessioning technology (such as Telnet or Terminal Services) to connect to a remote computer and manage it with WMIC.
  • Automated management using administrative scripting—you use WMIC to write a simple management script to automate the management of a computer (local, remote, or multiple computers—serially or simultaneously).

Aliases

The WMI infrastructure is accessible to you as you use WMIC through intermediate facilitators called aliases. Aliases are used to capture the features of a WMI class that are relevant to some specific task such as disk or network administration. Aliases can be used to provide better names for WMI classes, properties, and methods, or to arrange properties in useful output formats. The output formats can include specific property values or can be formatted in a manner appropriate to some specific presentation strategy or function. For example, an alias might have a "BRIEF" format that will list only property values essential for the identification of the objects visible through the alias. Management data is retrieved in XML format and processed by built-in or custom XSL output formats.

See also

WMI overview
Invoking WMIC
Using WMIC
Extending Aliases
Reference
Managing systems with WMIC
Windows Management Instrumentation Command-line (WMIC) tool


WMI overview

Microsoft Windows graphic

Windows Management Instrumentation overview

Windows Management Instrumentation (WMI) is the Microsoft implementation of WBEM, an industry initiative to establish standards for accessing and sharing management information over an enterprise network. WMI is WBEM-compliant and provides integrated support for the Common Information Model (CIM)—the data model that describes the objects that exist in a management environment.

WMI includes a CIM-compliant object repository, which is the database of object definitions, and the CIM Object Manager, which handles the collection and manipulation of objects in the repository and gathers information from WMI providers. WMI providers act as intermediaries between WMI and components of the operating system, applications, and other systems. For example, the registry provider draws information from the registry, while the SNMP provider provides data and events from SNMP devices. Providers provide information about their components, and might provide methods to manipulate the components, properties that can be set, or events that can alert you to changes in the components.

WMI can be used by computer management tools, such as Microsoft Systems Management Server, to help you manage your computers. WMI is also used by other Microsoft technologies and tools, such as Microsoft Health Monitor and Microsoft Operations Manager, and by other vendors of computer management systems. You can use WMI with programming or scripting systems (such as Windows Script Host) to retrieve configuration details about most aspects of your computer systems, including server applications, or to affect changes to your systems—see the WMI SDK for more details.

Several management tools are WMI-enabled, including System Properties, System Information, and the Dependencies component of Services. These components are briefly described below:

  • System Properties lets you view and change system properties on a local or remote computer. You can restart a remote computer to apply settings changes or to detect new hardware, view the computer name and domain information for other computers on your network, or change the settings for the virtual memory paging file on a computer that might run programs requiring a lot of memory. For more information about System Properties, see Using System Properties.
  • System Information collects and displays configuration information about your system. This is is especially useful when troubleshooting your system with a support technician. For more information, see Using System Information.
  • Services helps you manage the services on your computer. Services dependencies identify the services upon which the current service is dependent and the services that are dependent upon it. For more information about Services, see Using Services.
For technical information about developing for the WMI system, see the WMI Software Development Kit (SDK). The WMI SDK is released by Microsoft Developer Network (MSDN) as part of the Microsoft Platform SDK.


Invoking WMIC

You can choose to use WMIC in interactive mode or non-interactive mode. Interactive mode is useful if you are at the computer and entering a series of WMIC commands. Non-interactive mode is useful if WMIC is being used from a batch procedure or if you only need to execute one WMIC command.

Interactive mode

To start WMIC in interactive mode (from Start -> Run, or the command prompt):
wmic <CR>
You will then have the prompt:
wmic:root\cli>

("root\cli" is the default WMIC "role")

At the prompt you can enter an alias, command, or global switch, or you can enter /? for help.

When you are done with WMIC in interactive mode, you can use the Exit or Quit commands to exit WMIC.

Non-interactive mode

You can also use WMIC in non-interactive mode:
wmic /?

/? gives help, but you are then returned to the command shell you were in, not the WMIC command prompt. WMIC aliases, global switches or commands can also be used in non-interactive mode.


Using WMIC

WMIC is most easily used in interactive mode. However, for single operations or batched operations, non-interactive mode can be useful. See Invoking WMIC for details.

WMIC command-line help should be used to determine the available aliases and their verbs and switches.

Using aliases allows you to use WMI without understanding WMI schemas. If the default aliases are not sufficient for your needs but you want to use aliases or you want to make aliases available for other administrators, you can extend the aliases.

Global verbs (which are available for all aliases) perform functions related to the current alias. Global switches are available to adjust the usage of WMIC. Alias-specific verbs and switches might also be available—see the online help (/?) for the alias for details.

Commands are available for WMIC-specific functions.

If you are comfortable with WMI schemas, you can use the WMI schemas directly with WMIC.

You should keep in mind the security implications of WMIC.

If you have trouble using WMIC, you can troubleshoot the problem.

When you are done with WMIC, you can use the Exit verb to exit WMIC.

When you understand how to use WMIC, you are ready to manage systems with WMIC.

Notes

  • Ctrl-S can be used to pause output from any WMIC command at any time (any key will resume the output). Ctrl-C can be used to cancel the output (however, this will also terminate WMIC).
  • Use the /RECORD global switch to redirect WMIC output to a file.
  • Using WMIC on the local computer, you can connect to other computers with the /NODE global switch or within an alias file (if specified in the alias definition).


Command-line help

WMIC includes progressive help at the command line. At any level you can type /? and get additional details. By itself, /? will give you the available global switches and the aliases available in the current role. When used after an alias, /? will give you the verbs and switches available for that alias. After a verb, /? will give you the details for that verb.

For example:

wmic:root\cli> /?

For a list of the syntax and available aliases, including "process."

wmic:root\cli> process /?

Displays options available for the Process alias

/?:FULL will give all available details. This can be especially useful for switches.

Note

  • -? can be used in place of /?


Aliases

The WMI infrastructure is accessible to you as you use WMIC through intermediate facilitators called aliases. Aliases are used to capture the features of a WMI class that are relevant to some specific task such as disk or network administration. Aliases can be used to rename classes, rename properties and methods, or arrange properties in formats for output. The formats can include specific property values or can be formatted in a manner appropriate to some specific presentation strategy or function. For example, an alias might have a "BRIEF" format that will list only property values essential for the identification of the objects visible through the alias. Management data is retrieved in XML format and processed by built-in or customer-provided XSL documents.

Aliases are provided for the most commonly used classes of management information. You can add aliases for other classes.

Each WMIC role can have its own aliases. The /Role global switch can be used to change roles.

WHERE clause

Specific instances can be returned for an alias by including a WHERE() clause. The WHERE() clause must include the WHERE clause for a valid WQL query. See the WMI SDK for WQL syntax. The WHERE() clause must come right after the alias name. For example:

process where (processID>300) list brief

Aliases included with WMIC

For a list of aliases included with WMIC, enter /? at the WMIC command prompt.

For more information on a specific alias, type: <alias> /?


Verbs

Most aliases support the following verbs. Aliases might also support other verbs. To use verbs in WMIC, enter the alias name followed by the verb (see the alias help for details (<alias> /?)). If an alias does not support a verb, you will receive the message "provider is not capable of the attempted operation."
Verb | Action | Parameters or Verb-specific Switches | Example
ASSOC | Return the result of the query: Associators of {<wmi object>} Where <wmi object> is the path for the current object if the PATH or CLASS command is used. Otherwise the query is called for each of the instances of the alias. | Optionally, an output file format, TABLE, or MOF | PROCESS ASSOC
CALL | Executes methods | Method and parameter list if appropriate. Parameter lists are comma delimited. Use CALL /? for a list of available methods and theirparameterss for the current alias. | PROCESS CALL
CREATE | Creates a new instance and sets the property values for the new instance—this cannot be used to create a new class | Properties equated to values, delimited with commas. Use CREATE /? for a list of property names for the alias | ENVIRONMENT CREATE NAME="TEMP",VARIABLEVALUE="NEW"
DELETE | Deletes the current instance or set of instances—this can be used to delete a class | /INTERACTIVE (prompt to confirm) or /NOINTERACTIVE (don't prompt to confirm) | path DELETE
GET | Property get operations. | Property name or switch. See the table of switches for /GET below. Also use GET /? for a list of property names and switches for the alias | PROCESS GET NAME
LIST | Show data. LIST is the default verb. | See the tables of adverbs and switches for LIST below | PROCESS LIST BRIEF
SET | Property set operations | Properties equated to values, delimited with commas. Use SET /? for a list of property names for the alias | ENVIRONMENT SET NAME="TEMP",VARIABLEVALUE="NEW"
The List verb has the following adverbs. To use adverbs in WMIC, enter the alias name followed by a verb and adverb (see the alias help for details (<alias> /?)).
Adverb | Results
BRIEF | A core set of the properties
FULL | The full set of properties. This is the default set of LIST properties
INSTANCE | Just the instance paths
STATUS | The status of the objects
SYSTEM | System properties
Alias-specific or user format | Alias-specific or user defined formats may be defined providing distinct lists of properties and a format to be used in displaying them
The List verb has the following switches. To use verb-specific switches in WMIC, enter the alias name followed by a switch (verbs and adverbs might also be used) (see the alias help for details (<alias> /?)).
Switch | Effect
/TRANSLATE:<translation table> | Return the text returned by the command line using the translation table named by the command
/EVERY:<interval> | Return values every X seconds; X is determined by the interval
/FORMAT:<format specifier> | Specify a keyword or XSL file name to format the data, as stated in the note below
The Get verb has the following switches.
Switch | Effect
/VALUE | The output is formatted with each value listed on aseparatee line and with the name of the property
/ALL | The output is formatted as a table. /ALL is the default output format
/TRANSLATE:<translation table> | Return the text returned by the command line using the translation table named by the command
/EVERY:<interval> | Return values every X seconds; X is determined by the interval
/FORMAT:<format specifier> | Specify a keyword or an XSL file name to format the data, as stated in the note below

Notes

  • For both the List and Get verbs, the format specifier is used to designate either the name of an XSL file or the standard formats TABLE and MOF. /FORMAT:TABLE is equivalent to /ALL, which is the default output format. MOF formatted output could be captured to a file (using the /RECORD switch) and the file could be compiled using Mofcomp.exe on another computer to import it into WMI on the other system. However, be careful that computer-specific properties are edited as appropriate for the other computer.

Examples

The following examples demonstrate the effective use of the verbs and their adverbs and switches
  • PROCESS GET NAME /FORMAT:XML.XSL /TRANSLATE:BASICXML

    The process names are output in XML format. Without the /TRANSLATE switch, thecharacterssaroundd the values would be displayed as their HTML equivalents


Switches

Global switches are used to set defaults for the WMIC environment. You can view the current value of the conditions set by the global switches by entering the CONTEXT command.

Switch | Condition | Possible values | Default | Example
/NAMESPACE | Namespace containing classes referred to in aliases | Any namespace | root\cimv2 | /NAMESPACE:\\root or /NAMESPACE:SMS
/ROLE | Namespace containing aliases. When the role changes, the WMIC interactive command prompt changes to match. WMIC only has one role by default (\\root\cli), so you will only have to switch roles if you have a management product that has defined other roles or if other roles have been created at your organization | Any namespace that contains aliases | root\cli | /ROLE:\\root
/NODE | Computer names, comma delimited | Any computer name | Local computer name | /NODE:TESTSERVER1,TESTSERVER2
/IMPLEVEL | Impersonation level | Anonymous, Identify, Impersonate, Delegate | Impersonate | /IMPLEVEL:Anonymous
/AUTHLEVEL | Authentication level | Default, None, Connect, Call, Pkt, Pktintegrity, Pktprivacy | Default | /AUTHLEVEL:Pkt
/LOCALE | Locale | MS_409 (English), MS_411 (Japanese), MS_40B (Finnish) etc. | The default language on the computer when WMIC was installed | /LOCALE:MS_411
/PRIVILEGES | Enable all privileges | ENABLE or DISABLE | Disabled | /PRIVILEGES:ENABLE
/TRACE | The success or failure of all functions used to execute WMIC commands is displayed | ON or OFF | Off | /TRACE:ON
/RECORD | Record all output to a file | File name | Not set and there is no default file name | /RECORD:output.txt
/INTERACTIVE | Whether or not Delete commands should be confirmed or not | ON or OFF | Off | /INTERACTIVE:ON
/USER | A user name to be used by WMIC when accessing the /NODE computers or computers specified in aliases. You will be prompted for the password. A user name cannot be used with local computer. | Any user name | Not set | /USER:JSMITH or /USER:"" (to reset the user name and password to nothing)
/PASSWORD | A password to be used by WMIC when accessing the /NODE computers (possibly including the local computer). The password will be visible at the command line. | Any password | Not set | /PASSWORD:PASSWORD

Notes

  • To browse for possible ROLE and NAMESPACE namespaces, use the command CLASS __NAMESPACE. To see namespaces in other namespaces, use the /NAMESPACE switch to change namespaces. For example, use /NAMESPACE:\\root.
  • The GET and LIST verbs have verb-specific switches


Commands

The following commands are available at all times:

Command | Purpose
CLASS | Escape from the default alias mode of WMIC to access classes in the WMI schema directly
PATH | Escape from the default alias mode of WMIC to access instances in the WMI schema directly
CONTEXT | Display the current values of all global switches
QUIT | Exit from WMIC
EXIT | Exit from WMIC

For more information on using CLASS or PATH, see Using the WMI schema.

For more information on the global switches displayed by CONTEXT, see Switches.


Using WMI schemas

Use the CLASS command to escape from the default alias mode of WMIC to access classes in the WMI schema directly. Use the PATH command to escape from the default alias mode of WMIC to access instances or classes in the WMI schema directly.

The CLASS and PATH commands must be followed by valid paths to a WMI class or instance, respectively. The CLASS and PATH commands can then be used with the standard verbs and their verb switches.

Paths in WMIC are always relative to the Namespace global variable. Use \\root to indicate the root namespace.

The PATH command can be used to return specific instances by include .<propertyname> = <value>.

Examples

CLASS Win32_Environment

Lists all the environment variables

CLASS Win32_Environment CREATE Name="TEST",Username="DOMAIN\Username",VariableName="testvalue"

Creates a new environment variable

PATH  "Win32_Environment.Name='PROCESSOR_IDENTIFIER',Username='<SYSTEM>'"

Gets all the properties for a particular environment variable

PATH  "Win32_Environment.Name='PROCESSOR_IDENTIFIER',Username='<SYSTEM>'" GET VariableValue

Gets a particular property for a particular environment variable


Security

The WMI security access model is enforced on any call from WMIC to WMI. The operating system will enforce operating system-level security for any operations executed through WMI (for example, you cannot access files through WMI that you cannot access from Explorer). Providers might also enforce security for their systems.

When WMIC is used in a Telnet, Terminal Services, or similar session, all commands are carried out in the context of the user issuing the command.

WMIC is very powerful, allowing you to quickly do any task for which you have sufficient privileges. WMIC does not do sanity checks on the requested operations (for example, it will not ask if you really want to delete all instances of a class), so be careful when using WMIC.


Troubleshooting

WMIC returns standard error statements for any error that happens for operations initiated from the WMIC command line. Extended error information is available if the WMIC trace mode is enabled. Use the /TRACE global switch to enable trace mode.

WMI errors are only displayed in trace mode. WMI errors include WMI-specific details that are meant to be abstracted by WMIC. Therefore, when an error occurs, a standard WMIC message will be shown. If you require more information, you will have to switch to trace mode and use the WMI errors.

Common problems

  • Invalid parameter

    A parameter name is misspelled or doesn't apply to the object in question. A required parameter may also be missing—this can include key values or writable values. For example, when creating an environment variable, the name, user name, and variable value must all be specified.

  • Value map does not contain the input value for this property


Managing systems with WMIC

The following examples and best practices will help you to use WMIC:

  • process where (processID>300) list brief
    This demonstrates that you can list all processes on specified computers where the ProcessID is greater than 300, but limit the output to core information on those processes.
  • /node:(computer1),(computer2),(computer3)
    This demonstrates that you can add to the list of computers you want to retrieve information from (presuming you satisfy the security requirements).
  • class win32_processor get MaxClockSpeed
    This demonstrates that you can list only particularly useful properties from a class.
  • Simple reporting—you can use WMIC to do a query for the desired data, and dump the formatted output to an HTM file, which can be served to users like any other Web page. This can be done in in a batch procedure and thus automated.
  • Quick queries on the current computer—you can query for useful computer troubleshooting information, such as installed software.
  • Transferring WMI data between computers—you can output data to a MOF formatted file and then use Mofcomp.exe to compile the file on another computer, importing it to that computer.
  • Monitoring with the /Every switch—you can watch for dynamic processes on the computer, such as services being stopped.


Extending Aliases

When you are comfortable with WMIC, you might want to customize it to your own requirements and work style. Or you might want to extend it to work with additional namespaces and classes for systems you manage. Extending the aliases available to WMIC can allow you to achieve both of these goals. You can extend aliases by either adjusting the aliases that are provided with WMIC, or by creating your own aliases. You can also create additional formats to improve the output from aliases.

In order to understand how to extend aliases, you must first understand how aliases are implemented, in terms of alias namespaces and classes. You can then follow the procedures for creating or editing aliases.

If you want to create or edit formats, you must follow those procedures.

If you want to change the way that values are output in WMIC but you do not want to create a new format, you can consider creating or editing translation tables.

Caution

  • When editing default views, be sure to save your changes to a format outside of WMI. If you update WMI or the operating system, the new version of WMIC might return the aliases or output formats to the defaults, overwriting your changes.


Alias namespaces and classes

The default WMIC aliases are provided in the root\Cli namespace. You can add aliases in this namespace, or you can define aliases in other namespaces. If you define aliases in other namespaces, you must use the /ROLE switch to specify the namespace when using WMIC.

MSFT_CliAlias

The principal class in the schema is the MSFT_CliAlias class. Instances of this class are aliases. An MSFT_CliAlias instance has the following properties:

  • FriendlyName—the name of the alias. It must be unique.
  • Description—a description of the alias. This is the descriptive text when /? is entered at the WMIC command line.
  • Formats—a list, each of which has a name and a list of properties (objects of the class MSFT_CliProperty) to be displayed for that format. All formats are objects of the class MSFT_CliFormat.
  • Verbs—a list, each of which are the various behaviors available through this alias. The behaviors come in two forms:
    • Standard verbs which are directly supported by the utility.
    • User-defined verbs which must map to some method defined for the target of the alias.
    All verbs are objects of the class MSFT_CliVerb.
  • Qualifiers—a list, much the same as WMI qualifiers. All qualifiers are objects of the class MSFT_Qualifier.
  • Target—a WQL expression without the WHERE clause that designates which class and which of its properties the alias applies to.
  • PWhereclause—optional WHERE clauase that limits the Target. It may have substitution values which are the parameters of the alias. The substitution values are marked with #. If multiple parameters are needed, they are matched with the # markers in sequence.
  • Connection—details on which computers to connect to, the security details to be used, etc. If a connection is not specified, the computers to be accessed will be the value of /NODE, and the namespace is the value of /NAMESPACE. If a user name and password are not provided, then the value of /USER and /PASSWORD will be used, if available (otherwise the current account is used). Connection is an object of the class MSFT_CliConnection.

Classes for MSFT_CliAlias Properties

The following classes are used to define objects that are used in the properties of the MSFT_CliAlias class.

MSFT_CliFormat

Used in aliases.

The MSFT_CliFormat class defines a named format which will determine the set of properties to be displayed by the utility on a LIST command. Each MSFT_CliFormat instance has a name, a list of properties and a Format property which contains the name of a style sheet (XSL file) which must be used to format the property display.

MSFT_CliProperty

Used in formats.

Each MSFT_CliFormat instance contains a list of MSFT_CliProperty instances. Instances of the MSFT_CliProperty class define the set of properties to be displayed for a given format. Each MSFT_CliProperty instance has a derivation which might be either a constant, the name of a property or a WMI command line GET command. Each MSFT_CliProperty also has a localized description.

Formats are related to a specific XSL by the NAME property of the format object. FULL, BRIEF, and INSTANCE correspond to particular XSLs, and the NAME could specify the name of a custom XSL file.

MSFT_CliVerb

Used in aliases.

Instances of the MSFT_CliVerb class represent verbs defined for the alias. Verbs are either standard verbs (GET, LIST, CALL and SET) or user defined verbs. Standard verbs will have descriptions and usages but will not have parameters.

MSFT_CliParam

Used in verbs.

MSFT_CliQualifier

Used in both aliases and verbs. WMIC qualifiers serve the same purpose as WMI qualifiers.

MSFT_CliConnection

Used in aliases.

Other Alias Classes

The following classes are used with WMIC functionality that doesn't involve the MSFT_CliAlias class.

MSFT_CliTranslateTable

Used with GET /TRANSLATE and LIST /TRANSLATE verb-specific switches. The only translation table included with WMIC is BasicXml.

MSFT_CliTranslateTableEntry

Used in the translation table.

MSFT_CliSeeAlso

The MSFT_CliSeeAlso association provides a relationship between an alias and any aliases with some kind of functional relationship to the alias. You can extend the alias schema to allow aliases to be categorized and navigated in various ways.

More details on this class will be included in the next version of this help.

Notes

  • When browsing the role namespaces using WMI browsing tools (such as CIM Studio), only the MSFT_CliAlias and MSFT_CliTranslateTable classes have instances. Their properties might includes objects of the other classes, but the other classes will not have instances of their own. CliSeeAlso might also be an exception to this note.
  • For this reason, when creating aliases, you primarily create instances in the MSFT_CliAlias class. You create instances of the other classes as properties of the MSFT_CliAlias class or as properties of its properties.


Creating and editing aliases

You can create aliases interactively using a tool such as CIM Studio (from the WMI SDK). You can also write aliases as MOF or XML files. The MOF or XML files can then be used to register the alias. Aliases are registered with WMI by compiling the MOF form of the alias. XML alias files can be translated to MOF using a style sheet (using the WMICliMofFormat.xsl file). XML alias files are registered at the command line. The command line defines an XSL parser to transform the alias file into WMI format and import the aliases into a WMI schema.

When browsing the role namespaces using WMI browsing tools (such as CIM Studio), only the MSFT_CliAlias and MSFT_CliTranslateTable classes have instances. Their properties might includes objects of the other classes, but the other classes will not have instances of their own. (CliSeeAlso might also be an exception to this note.) For this reason, when creating aliases, you primarily create instances in the MSFT_CliAlias class. You create instances of the other classes as properties of the MSFT_CliAlias class or as properties of its properties.

Localization is supported through the use of localized text arrays defined in the schema. Localization of aliases descriptions is done through the MFL file (more details on this will be provided in the next version of this help; the WMI SDK might also provide details).

Adding Roles

Any WMI namespace can serve as a role. However, without additional steps, the role will not have WMIC's interactive help or the base classes required for aliases. The easiest way to make those available is to copy WMIC's Cli.mof file and change the namespace reference to the namespace that is to be used as a role. The new file can then be compiled with MOFCOMP.exe. Aliases can then be added as described above.

Additional Topics

Additional topics to be covered in the next version of this help:
  • Working with MOF, XSL, and possibly other files to define aliases (and output formats and translation tables).
  • How to embed remote computer names in aliases.


Creating and editing formats

Formats are WMIC-provided formats or XSL files. The format XSL files are kept in the WBEM directory. Formats are used with GET, LIST or ASSOC. Specific formats can be specified using GET /FORMAT:, LIST /FORMAT:, GET /ALL, GET /VALUE, or ASSOC /FORMAT:.

If you create custom formats, you should also define them in the Formats property of the MSFT_CliAlias class. Each format must have a unique name (unique within the alias).

WMIC includes the following output formats:

  • wmiclimofformat.xsl—converts XML data to MOF format. If aliases or other WMI objects are defined in XML format, this XSL can be used to convert them to MOFs so that they can be MOFCOMPed. - /FORMAT:MOF format.
  • wmiclitableformat.xsl—/ALL or /FORMAT:TABLE.
  • wmiclitableformatnosys.xsl—same as wmiclitableformat.xsl except that it does not have the ability to display WMI "system" properties (properties for the WMI path of instances, etc.).
  • wmiclivalueformat.xsl—/VALUE format—one line per value.
WMI includes additional XSL files that could be useful when using WMIC:
  • mof.xsl—converts XML data to MOF format. If aliases or other WMI objects are defined in XML format, this XSL can be used to convert them to MOFs so that they can be MOFCOMPed.
  • xml.xsl—to output XML data in XML format. All WMIC data is extracted in XML format, so this format will give you data the way that WMIC sees it. This can be useful for creating your own XSL files. Outputting data in XML format is also useful if you want to provide the data to systems that accept XML data.
  • hform.xsl—html output—the data is displayed in a vertical table (one row per property or instance name). The table can be very long.
  • htable.xsl—html output—the data is displayed in a horizontal table (one row per instance). The table can be very wide.
  • texttable.xsl—the same as wmiclitableformatnosys.xsl.
  • texttablewsys—the same as wmiclitableformat.xsl.
  • textvaluelist—similar to wmiclivalueformat.xsl except that property names are not included on each line and the format is more compact.

How to create or edit formats

Use an XSL editor. You might want to first capture some XML data to use for experimenting while using the XSL editor.

An an optional step, add the formats to the alias class. This makes the formats discoverable and easier to use.


Creating and editing translation tables

Like formats, translation tables allow you to change the output of WMIC commands to suit your needs. Translation tables are not as flexible or powerful as formats, but they are much simpler to create and edit.

Translation tables are used when you specify /TRANSLATE on LIST or GET verbs. The only translation table included with WMIC is BasicXML. It converts the HTML symbols for greater than and less characters into the characters themselves.

Translation tables are defined in the MSFT_CliTranslateTable WMI class.


Reference

To better understand WMIC, you might want to understand:
  • Terminology
  • Formal WMIC command syntax
  • WMIC architecture


Terminology

This topic is temporary. These terms will be completed and then included in the glossary.
Adverb
a parameter to a verb clarifying what should be done
Alias
a WMIC-specific definition of WMI classes. Aliases have simplified names and property names, which should be easier to relate to. Aliases also have verbs and formats which make it easier to use the classes. Aliases might contain details for using the classes on remote or multiple computers.
Associator
a relationship between instances
Class
a definition of WMI objects
Global Switch
a switch that applies to the operation of WMIC and all aliases
Instance
a specific piece of data
Interactive
actions must be confirmed
Interactive Mode
when WMIC is used from its own command prompt
Method
an action that a WMI class or instance is capable of executing
MOF
Management Object Format—the format of flat files containing WMI data
Namespace
a virtual location within which WMI classes and instances can be located
Non Interactive Mode
when WMIC is used from another command prompt, such as the operating system command prompt
Object
the implementation of an instance
Object Path
the WMI path that can be used to locate an instance or class
Path
the location of a WMI instance or class
Properties
details
Role
a namespace with WMIC information
Schema
an abstract definition of a namespace
Switch
a qualifier indicating how things should be used
Translation table
a means to translate WMIC output
Verb
a parameter to an alias indicating what should be done with the alias
XML
eXtended Markup Language—a standard for describing data
XSL
eXtended Style Language—a standard for describing how to display XML data


Formal WMIC command syntax

The WMIC command-line BNF:
<WMI Command> | ::= | [<global switch list>] <command>
<global switch list> | ::= | <global switches> | <global switches> <global switches list>
<global switches> | ::= | (/NAMESPACE | /ROLE ) [:<namespace>] | /NODE [:<computer id list>] | /IMPLEVEL [:<ilevel>] | /AUTHLEVEL [:<alevel>] | /LOCALE [:<locale identifier>] | /PRIVILEGES [:<property>] | /TRACE [:<option>] | /RECORD [:<file path>] | /INTERACTIVE /USER [:<user id>] | /PASSWORD [:<password id>] | /? [:<help type>]
<computer id list> | ::= | <computer id> | <computer id> <computer id list>
<command > | ::= | (<alias> [ <WMI object>] | [<alias>] <path where>) [<verb clause>] | EXIT | CLASS [<class path expression >] [<verb clause>] | RESTORE [ <restore file path>]
<path where> | ::= | [PATH (<path expression> | <class path expression> )][ WHERE <where clause>]
<alias> | ::= | !! name for the alias. The name will be unique in the context of the namespace in which the alias is defined. Note CLASS, PATH, WHERE, RESTORE and EXIT cannot be used as alias names as they appear in the same location in the syntax.
<WMI object> | ::= | <parens> <alias parameters> <parens> | <alias parameters>
<path expression> | ::= | !! A WMI path expression including a key clause
<where clause> | ::= | !! A WQL where clause optionally surrounded by parenthesis
<class path expression > |  | !! A WMI path expression that does not include a key clause
<alias parameters> | ::= | !! one or more space delimited literals that will be used as substitutions in the alias’ PWhere value.
<verb clause> | ::= | (<verb> [<verb parameters>] | <standard verb>) [<verb switches>]
<verb> | ::= | <property name> | <identifier> | <method name>
<verb switches> | ::= | /INTERACTIVE | /NOINTERACTIVE
<verb parameter> | ::= | <actual parameter> | <actual parameter> , <verb parameter>
<standard verb> | ::= | <get verb> | <list verb> | <assoc verb> | <call verb> | <create-set verb> | <delete verb>
<identifier> | ::= | <idhead> [<idrest>]
<idhead> | ::= | <letter>
<idrest> | ::= | <identifier> [<letter> | <digit>]
<get verb> | ::= | GET [<property list>] [<get switches>]
<property list> | ::= | <property name> | <property name> , <property list>
<list verb> | ::= | LIST [<list format>|<list switches>]
<assoc verb> | ::= | ASSOC [<format specifier>]
<call verb> | ::= | CALL <method name> [<actual parameter list>]
<actual parameter list> | ::= | <actual parameter> | <actual parameter , <actual parameter list>
<create-set verb> | ::= | SET <assign list>| CREATE <assign list>
<assign list> | ::= | <property name> = <property value> | <property name> = <property value> <assign list>
<delete verb> | ::= | DELETE
<get switches> | ::= | /VALUE | /ALL | /TRANSLATE :<table name> | /EVERY :<interval> | /FORMAT [:<format specifier>] | /DESCRIPTION [:<code page>]
<interval> | ::= | !! numeric value indicating frequency within which values should be returned
<format specifier> | ::= | :<xsl file name> | :TABLE | :MOF
<list format> | ::= | BRIEF | INSTANCE | SYSTEM | STATUS | FULL | <user format>
<list switches> |  | /TRANSLATE | /EVERY :<interval>| /FORMAT [:<format specifier>]
<help type> | ::= | : BRIEF | : FULL


WMIC architecture

This topic discusses the relationship of WMIC to WMI, to other computers, and to scripting languages. It also discusses the relationship between aliases, formats, translation tables, and other WMIC elements.

WMIC has an engine to parse, interpret, and execute alias operations called out from the command line. That the engine is an .exe entitled WMICli.exe run on the computer that the user is connected to. Any extension to the WMI command line interpreter, etc., must be done through the addition of alias file definitions or registrations.

Aliases are extracted as XML alias files from WMI schema. These files are defined with a context (XML DTD and transform with an XSL) that allows users to easily define further information that they need to surface and in manner in which they can surface it. The XML form of the alias may be used for documentation or replication.

The WmiCli.exe receives a command through its stdin interface. The command is parsed by the utility and if it involves an alias, the alias definition is fetched from the current WMI operational namespace (root\ops by default). The utility interprets the original command in the light of the alias command and current environmental settings (for example the current target namespace). The command is executed as a series of WMI API calls against the target namespace. Any namespace may be used as a target given that the namespace is consistent with the alias being processed.

The information returned for the API calls is retrieved in an XML format. The retrieved data has the XSL style sheet (associated with the alias) applied to it for presentation formatting and the resulting text presented back to the user through the stdout interface. The Target system and management system need not be the same computer, though the original caller must have sufficient credentials to access the target computer.

The style sheet applied to the output will default to the standard FULL style sheet if none is specified.