Windows OS extract CD key OFFICIAL WAY

Soldato
Joined
17 Jul 2008
Posts
7,439
is there a microsoft way to work out what CD key was used to install a 2003 / 2000 server?

I know magicjelly bean will do it but we cannot use anythign non MS

I suspect the answer is its not possible but I thought I'd ask the question

ta for looking
 
There is no official microsoft way because they don't want you doing it.

Of course there is. Don't be silly. They just don't want to make it too easy! :p

First, you will need to install Powershell. You can do that by installing the Windows Management Framework Core for your platform. Powershell is an MS product.

Once installed run powershell.exe and type the following:

Code:
Set-ExecutionPolicy RemoteSigned

Then create a new text file, call it get-productkey.ps1 and paste in this code:
Code:
# create table to convert in base 24 
$map="BCDFGHJKMPQRTVWXY2346789" 
# Read registry Key 
$value = (get-itemproperty "HKLM:\\SOFTWARE\Microsoft\Windows NT\CurrentVersion").digitalproductid[0x34..0x42] 
# Convert in Hexa to show you the Raw Key 
$hexa = "" 
$value | foreach { $hexa = $_.ToString("X2") + $hexa } 

# find the Product Key 
$ProductKey = "" 
for ($i = 24; $i -ge 0; $i--) 
{
    $r = 0 
    for ($j = 14; $j -ge 0; $j--) 
    { 
        $r = ($r * 256) -bxor $value[$j] 
        $value[$j] = [math]::Floor([double]($r/24)) 
        $r = $r % 24 
    } 
    $ProductKey = $map[$r] + $ProductKey  
    if (($i % 5) -eq 0 -and $i -ne 0) 
    { 
        $ProductKey = "-" + $ProductKey 
    } 
} 
"Product Key: $ProductKey"

Then back in the console run:
Code:
C:\scripts\get-productkey.ps1

Magic! :)

Change the path above to suit where you saved your ps1 file. The first command you entered [Set-ExecutionPolicy] needs only ever be done once. So you only need to run the second command in future [from the same machine that is].


If you cannot install PowerShell for whatever reason, there is also a VBScript version here: http://www.visualbasicscript.com/Retrieve-Windows-Product-Key-m42793.aspx

I haven't tested it, but is probably quicker if this a one-off and you never intend to use PS. :)
 
Back
Top Bottom