Learning WMIC: part 1 – Basic Syntax

WMIC is a powerful means to access the Windows Management Interface from the command line. More information about WMI can be found at the Wikipedia page – https://en.wikipedia.org/wiki/Windows_Management_Instrumentation

There are a couple of scenarios for using WIMIC – against the local computer and against a remote computer. With either of the situations, WMIC will run by default with the privileges of the user that is logged in. If that user is not an administrator, either local or domain, then the abilities will be limited.

As with many Windows commands, WMIC may be used interactively, or by issuing the entire command.

From the command prompt, enter wmicand you will enter the wmic environment

C:\Users\dlstrom> wmic

To get help, simply issue the /? command and press <enter>

At this point everything is being run locally with the privileges of the logged-on user.

I’ve found my mind works better in non-interactive command-line mode rather than interactive mode. That’s what we’ll be using most of the time.

Try this from the command line – wmic startup. This should return LOTS of information that is almost overwhelming.

Now, do wmic startup list brief to a more readable list of startup programs. Remember that this is all running against the local computer.

I’ve found that making the command window as wide as possible helps with wrapping of lines and makes the output more readable.

WMIC can also be run against other Windows computers on the network.

wmic /node:<HOSTNAME> startup list brief executes on another computer. This requires knowing the hostname, and having permissions to access that computer.

If running with local user privileges and trying to access information on the remote host, you might get this…

C:\Users\dlstrom>wmic /node:CONTROL1 startup list brief
Description = Access is denied.

This means that I’m logged in on my computer with user-level privileges that are not allowed on CONTROL1. The solution is some additional switches on the command line…

C:\Users\dlstrom>wmic /node:CONTROL1 /user:<USERNAME> /password:<PASSWORD> cpu get name
Intel(R) Xeon(R) CPU E3-1230 v3 @ 3.30GHz

That USERNAME and PASSWORD must be a valid account on CONTROL1 in order to work. Note that if either the USERNAME or PASSWORD includes a hyphen, then it must be enclosed in double-quote marks.

If you ever get confused as to which host you are working with, this command will identify the nodes you are querying when in interactive mode…


That’s it for now. More to come…

Posted in Learning, Technical and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *