UNIX / Linux keyboard.

Recovering the Windows License Key, and Other Advanced Maintenance

WMIC: Command-Line Access to the Windows Management Instrumentation

WMIC is the command-line tool for accessing the Windows Management Instrumentation. This provides a single interface to a wide variety of information, addressing the hardware, installed operating system and software, system configuration, and running system state.

I read that you can use the tool to recover the License Key used to install Windows. That got my attention! If you're about to do something risky, and want to be able to reinstall, this is an important step. It's absolutely needed if you have install media but aren't 100% certain that you have the license key.

Let's do this one first. It's a capital letter O and not the digit zero:

C:\>wmic path softwarelicensingservice get OA3xOriginalProductKey
OA3xOriginalProductKey
NYYM6-CKJV9-7HMB3-D8ZQY-43KTP 

You can get a list of all available values:

C:\>wmic path softwarelicensingservice get /?
[... much output ...] 

You can get context-dependent help by typing a partial command and then /? to see the possibilities.

Microsoft provides some documentation, although it doesn't go much beyond defining the syntax. Most of the capability is unmentioned there.

Hardware Details

You can make a simple request for the model name.

C:\>wmic computersystem get model
Model
ASUSPRO P5440UF 

Or, ask for the amount of RAM.

C:\>wmic computersystem get totalphysicalmemory 

What else is available? Ask the tool to show you the list

C:\>wmic computersystem get /?

You can ask for everything associated with the object.

C:\>wmic computersystem get * 

That will display a lot of information. You can direct the output into a file, as shown below. The /output: option must be right after the command wmic and before any parameters.

C:\>wmic /output:"C:\output.txt" computersystem get *

Several hardware systems have their own data stores

C:\>wmic bios get serialnumber
SerialNumber
J7NXCV00N252275

C:\>wmic bios get /?
[... lots of output ...]

C:\>wmic bios get *
[... even more output ...]

C:\>wmic baseboard get product,manufacturer,version,serialnumber
Manufacturer           Product  SerialNumber       Version
ASUSTeK COMPUTER INC.  P5440UF  N0CV1826MB0005082  1.0

C:\>wmic diskdrive get name,size,model
Model                       Name                Size
SAMSUNG MZVLW512HMJP-00000  \\.\PHYSICALDRIVE0  512105932800 

OS Details

Some objects have both brief and full options, among others.

C:\>wmic os list brief
BuildNumber  Organization  RegisteredUser  SerialNumber             SystemDirectory      Version
17763                                      00330-51226-37474-AAOEM  C:\WINDOWS\system32  10.0.17763

Installed Software

A fantastic collection of information is available, but it's of unwieldy size and format. So, ask the tool to store it in a file, and to format it as an HTML table. The /format: must come at the very end.

C:\>wmic /output:C:\Users\BCromwell\prod.html product get /format:hform 

System Configuration

Ask for a list of startup tasks.

C:\>wmic startup list brief
[... lots of output...] 

As for lists of defined users, groups and system accounts.

C:\>wmic useraccount list
[... lots of output...]

C:\>wmic group list
[... lots of output...]

C:\>wmic sysaccount list
[... lots of output...]

System State

You can get the function of the UNIX-family ps command, with much more typing but no memorization of single-letter options.

C:\>wmic process get name,processid | more
Name                     ProcessId
System Idle Process      0
System                   4
Registry                 120
smss.exe                 464
csrss.exe                636
wininit.exe              736
services.exe             808
lsass.exe                828
svchost.exe              944
svchost.exe              972
fontdrvhost.exe          992
[... and so on ...]]

C:\>wmic service list brief
[... lots of output ...]

C:\>wmic environment list | more
[... search path,
      filename extensions considered executable,
      various temporary area definitions,
      and much more ...]

C:\>wmic share list 

Event Logs

This becomes very powerful, with increasingly complex syntax.

C:\>wmic ntevent where (message like "%logon%") list brief
[... lots of output ...]