Dirk Van den Berghe SharePoint Blog

real admins use stsadm, but admins from hell use powershell.

How To Recover Your SharePoint 2007 Product ID by Bert Johnson

On my post about the SP2 bug, I had a comment by Bert Johnson about a post of his explaining how to recover the SharePoint 2007 Product ID from your system. This is indeed very handy if you do not happen to have it or find it anymore and do not want to bother your customer for it loosing face (again Big Smile)

Bert wrote a vbs script that decodes the Product ID from the registry key blob data where it resides.

Thanks Bert for sharing this information, which will probably help a lot of us out there.

Subscribe to Bert's blog with this Feed: http://blogs.pointbridge.com/Blogs/johnson_bert/_layouts/listfeed.aspx?List={071A5AE9-9B1F-44E7-8AF7-C0BC07CF531D}

The original post can be found at http://blogs.pointbridge.com/Blogs/johnson_bert/Pages/Post.aspx?_ID=10 .

Here is the script :

' Extract MOSS 2007 Product ID
' Written by Bert Johnson (PointBridge)
' http://blogs.pointbridge.com/Blogs/johnson_bert/Pages/Post.aspx?_ID=10

Const HKEY_LOCAL_MACHINE = &H80000002
Set reg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

wscript.echo GetKey("SOFTWARE\Microsoft\Office\12.0\Registration\{90120000-110D-0000-0000-0000000FF1CE}", "DigitalProductId")

Public Function GetKey(path, key)
    Dim chars(24), prodid
    Dim productkey(14)

    reg.GetBinaryValue HKEY_LOCAL_MACHINE, path, key, prodid
    
    For ib = 52 To 66
        productkey(ib - 52) = prodid(ib)
    Next

    'Possible characters in the Product ID:
    chars(0) = Asc("B")
    chars(1) = Asc("C")
    chars(2) = Asc("D")
    chars(3) = Asc("F")
    chars(4) = Asc("G")
    chars(5) = Asc("H")
    chars(6) = Asc("J")
    chars(7) = Asc("K")
    chars(8) = Asc("M")
    chars(9) = Asc("P")
    chars(10) = Asc("Q")
    chars(11) = Asc("R")
    chars(12) = Asc("T")
    chars(13) = Asc("V")
    chars(14) = Asc("W")
    chars(15) = Asc("X")
    chars(16) = Asc("Y")
    chars(17) = Asc("2")
    chars(18) = Asc("3")
    chars(19) = Asc("4")
    chars(20) = Asc("6")
    chars(21) = Asc("7")
    chars(22) = Asc("8")
    chars(23) = Asc("9")

    For ib = 24 To 0 Step -1
        n = 0

        For ikb = 14 To 0 Step -1
            n = n * 256 Xor productkey(ikb)
            productkey(ikb) = Int(n / 24)
            n = n Mod 24
        Next

        sCDKey = Chr(chars(n)) & sCDKey
        If ib Mod 5 = 0 And ib <> 0 Then sCDKey = "-" & sCDKey
    Next

    GetKey = sCDKey
End Function
Simply save that to a file named "ExtractMOSS2007ProductID.vbs" and run it to recover your key.  Once recovered, re-apply your Product ID through Central Admin, as outlined in KB971620.
Posted: 05-28-2009 22:27 by Dirk | with 1 comment(s)
Filed under: , , ,

Comments

Mark said:

Thanks! Just had to change the '110D' in line 8 to '0017' and it worked perfect! I got a new laptop for work and needed to re-install SharePoint Designer on the new laptop, but didn't have the product key recorded anywhere. This saved me a lot of hassle.

# augustus 24, 2009 5:48
Leave a Comment

(required) 

(required) 

(optional)

(required)