I'm a huge fan of command line utilities that provide fast, no-nonsense access to information and allow me to perform some basic configuration tasks. Evidently there are some people at Microsoft who are as well, because they created the Windows Management Instrumentation Command-line utility, or WMIC.

 

I could not begin to describe everything you can do with it, but allow me to throw out a few commands to give you some ideas.

 

This command gets you the status of all the printers on the machine:

 

     C:> wmic printer list status

 

If I want to know the status of the printers on a remote machine, I can provide a node name:

 

     C:> wmic /node:"some-other-machine" printer list status

 

This command collects the environment variables from several machines and display it in list format:

 

     C:> wmic /node:"machine1", "machine2" environment get /format:list

 

This command gets information about the monitors that are attached to these computers (I can add as many as I want in a comma separated list). It provides some useful data like manufacturer, HxW, resolution, etc. By using the format type htable, I can create a web page that contains this information. It's a pretty cool way of gathering information if, lets say, you were trying to find out who the candidates are for a monitor replacement. BTW, wmic can get information about any hardware components in the system and also can report on installed software, the BIOS, etc.

 

     C:> wmic /node:"machine1", "machine2", "machine3"  desktopmonitor get /format:htable > monitors.htm

 

And now, two of my personal favorites!

 

This one shows me if a certain executable is running on any of the computers in my list. The 'where name=' stuff filters out information about all the other processes. Without that option, it would show me all processes running on the system(s). In this example, I used it to find out if any of these machines were running iCDB Server Monitor. Those that were displayed their hostname (csname) and the executable path. Without those two parameters, it would show me much, much more information about the process (way more than needed).

 

C:>wmic /node:"orw-foster-w7", "orw-kfost-t5610", "kvmw7x64" process where name="iCDBServerMonitor.exe" get csname, executablepath

CSName         ExecutablePath

ORW-FOSTER-W7  C:\MentorGraphics\7.9.5EE\SDD_HOME\iCDB\win32\bin\iCDBServerMonitor.exe

KVMW7X64       C:\MGC\RSCM\EEVX.1\SDD_HOME\common\win32\bin\iCDBServerMonitor.exe

 

Here's an idea: Run a scheduled task that uses wmic to look for a particular process, dump that information in htable format, and copy that .htm to a web page. Now you can see who is running what at a glance.

 

I mentioned that you could also use it to perform some configuration tasks. In this example, I'm using it to change the value of the existing MGLS_LICENSE_FILE environment variable on a remote machine. As before, I could have a number of machines in my list separated by commas. Note that the output below the command line confirms that the operation was successful. I could easily create variables with wmic as well.

 

C:>wmic /node:kvmw7x64 environment where name="MGLS_LICENSE_FILE" set variablevalue="1717@wv-lic-01"

Updating property(s) of '\\KVMW7X64\ROOT\CIMV2:Win32_Environment.Name="MGLS_LICENSE_FILE",UserName="<SYSTEM>"'

Property(s) update successful.

 

Give wmic a try! It may take a while to get the hang of the syntax, but it's worth it if you need to do a lot of remote administration.

 

If you come up with some good ones, please share!

 

-K