wmic is a shell command similar to netsh, covered in Chapter 11, “Configuring Windows 7 with netsh.” You can enter wmic from the command prompt to enter the wmic shell. The wmic shell prompt starts in the root\cli name space, from which you can then enter commands. For example, if you want to get detailed information on the computer, you can use the computersystem list full command:
C:\>wmic
wmic:root\cli>computersystem list full
You can also enter the full wmic command from the command prompt by preceding it with wmic. For example, the following command provides the same output as the previous command:
C:\>wmic computersystem list full
If you were writing this within WMI (not wmic), you would have to understand the query language, and the query would look something like this:
Select * from Win32_ComputerSystem
However, thanks to the wmic built-in aliases, you don’t have to learn the query language to use wmic.
The wmic command includes several switches. Some of the more common switches are listed in the following table.
Tip
Some commands don’t recognize the switch unless it is entered before the command (right after wmic) rather than after the command (at the end of the wmic command string).
Switch
Description
/? [:brief | :full]
C:\>wmic /?
C:\>wmic /?:full
Shows the syntax of all global switches and aliases.
The default listing is brief, but you can also specify full to get a more verbose listing of help.
/node:remotecomputerwmic /node:remotecomputercommand
C:\>wmic /node:win7pcg computersystem
C:\>wmic /node:win7pcg printer list brief
You can use the /node switch to retrieve information from any remote computers.
The first example retrieves information with the computersystem alias, and the second example uses the printer alias.
Provides the username to be used during the session or for the command. You will be prompted to enter a password.
This is useful when connecting to remote systems, but it can’t be used to change the credentials on the local system.
Identifies where to redirect the output. The output is normally sent to the screen but can be sent to the Clipboard or to a file. The /output switch needs to go before the alias.
When sending it to a file, the path must exist or the command will fail with an “Invalid file name” error.
Tip
The normal redirect symbol (>) can also be used, as in the following example: