Windows includes a little-known utility named slmgr (which presumably stands for Software License ManaGeR) that allows the administrator to install and uninstall Windows product keys (may be useful when upgrading). Both installation and uninstallation have to be done from the command line running as Administrator.
Uninstallation is done in two steps. First, the administrator needs to display values associated with the currently installed key:
When this command is complete, Windows shows a message box showing a series of values associated with the currently installed product key, including Activation ID. The Activation ID (a series of numbers, letters, and dashes) is used in the second step:
slmgr /upk [Activation ID goes here]
If everything went well, Windows will show a message box saying Uninstalled product key successfully.
Product key installation is a simpler single-step procedure:
slmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
The Xs, of course, represent the product key. If everything went well, Windows displays a message box saying Installed product key XXXXX-XXXXX-XXXXX-XXXXX-XXXXX successfully.
To display values returned by slmgr in the console, rather than in a message box, or save them into a text file, use cscript. For example:
cscript slmgr.vbs /dlv
cscript slmgr.vbs /dlv > C:\Users\Public\licinfo.txt
The first command will display output in the console, the second, save it into the specified text file.