How to get windows 7 cd key from command prompt or linux live disk?

No, you cannot do it from WinRE command line

Connect the non bootable drive to another Windows PC using a usb to hard drive adapter, install Product Key on the Host PC, run Product key and use File > Select Source.

When the new window opens tick the third radio button, browse to the Windows folder on the non boot drive and hit ok.

enter image description here


I've had really good success with the Magic Jelly Bean KeyFinder tool with MS-Windows 7 (32-bit and 64-bit editions), plus other versions of MS-Windows and most MS-Office products too:

  Magic Jelly Bean KeyFinder
  http://www.magicaljellybean.com/keyfinder/

enter image description here


It is possible to get the key from a Linux live disk (e.g. a Ubuntu Live DVD ), or any linux system that has access to the computer's drive (booted from usb, dual booted etc) - this may also be possible from another windows system without third party apps (example). Then you can get the licence by:

  1. Get a registry reading/editing tool. I used chntpw, it is currently available in the Fedora and Ubuntu software repositories.

  2. Get the registry data. You will need the file that contains the registry data from HKLM\SOFTWARE, this should be located at /Windows/System32/config/SOFTWARE (text case may vary, could be /WINDOWS/system32/config/SOFTWARE etc). If you can read the hard disk this should be accessible

  3. Extract the data. Run chntpw with the path to the registry file - e.g. with the windows partition mounted on /mnt:

    chntpw -e /mnt/Windows/System32/config/SOFTWARE
    

    And get the data from the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId key - you may be able to use dpi command, otherwise you can read the key data directly using hex Microsoft\Windows NT\CurrentVersion\DigitalProductId.

If you don't succeed, you could check the hardware to see if it has the key embedded using the answers here. Or check for a sticker that came with the computer with the licence key written on.

Also if the Windows is a retail or OEM licence, you may just find a unique ID as the key is for use one time only.

More info:

  • chntpw site probably
  • chntpw tutorial (for resetting passwords)
  • How to Geek - How to Find Your Lost Windows or Office Product Keys