Is this script legal to recover the OEM Product-Key?

Is known as ShowKey.vbs, but I want to know if it is legal to use:

Set WshShell = CreateObject("WScript.Shell")
Key = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
DigitalID = WshShell.RegRead(key & "DigitalProductId")

ProductName = "Product Name: " & WshShell.RegRead(Key & "ProductName") & vbNewLine
ProductID = "Product ID: " & WshShell.RegRead(Key & "ProductID") & vbNewLine
ProductKey = "Installed Key: " & ConvertToKey(DigitalID)
ProductID = ProductName & ProductID & ProductKey

If vbYes = MsgBox(ProductId & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "Windows Key Information") then
   Save ProductID
End if

Function ConvertToKey(Key)
    Const KeyOffset = 52
    isWin8 = (Key(66) \ 6) And 1
    Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
    i = 24
    Chars = "BCDFGHJKMPQRTVWXY2346789"
    Do
        Cur = 0
        X = 14
        Do
            Cur = Cur * 256
            Cur = Key(X + KeyOffset) + Cur
            Key(X + KeyOffset) = (Cur \ 24)
            Cur = Cur Mod 24
            X = X -1
        Loop While X >= 0
        i = i -1
        KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
        Last = Cur
    Loop While i >= 0
    If (isWin8 = 1) Then
        keypart1 = Mid(KeyOutput, 2, Last)
        insert = "N"
        KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
        If Last = 0 Then KeyOutput = insert & KeyOutput
    End If
    a = Mid(KeyOutput, 1, 5)
    b = Mid(KeyOutput, 6, 5)
    c = Mid(KeyOutput, 11, 5)
    d = Mid(KeyOutput, 16, 5)
    e = Mid(KeyOutput, 21, 5)
    ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e
End Function

Function Save(Data)
    Const ForWRITING = 2
    Const asASCII = 0
    Dim fso, f, fName, ts
    fName = "Windows Key.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.CreateTextFile fName
    Set f = fso.GetFile(fName)
    Set f = f.OpenAsTextStream(ForWRITING, asASCII)
    f.Writeline Data
    f.Close
End Function

April 13th, 2015 12:09pm

Hi!

From what I can understand, this is in a bit of a "gray zone", showing the key isn't illegal, but if you plan on using it again, when doing a re-install of the system it isn't allowed, or use it on another computer for that matter,

In these cases, you should use the recovery media that is shipped with your computer or download it from the manufacturer.

The OEM recovery media should match the product version originally preinstalled on the system; no other image may be used to restore the system to its original state.

I would contact MS and see what they are saying, depending on what you need the key for of course:
https://support.microsoft.com/en-us/kb/326246?wa=wsignin1.0

Best regards
Andreas Molin

Free Windows Admin Tool Kit Click here and download it now
April 14th, 2015 7:21am

Thanks for the answer Andreas Molin, the problem when is used the recovery media, must make backup of your data and reinstall programs you had at the moment.

I ask this, is because I saw cases when for some razon OEM OS must be activated even when is the same OS and is not been modified, but for some reason the system cannot be activated and have another product key active.

I know sometimes the people add Windows Features like media center and they even don't know this affect the version of the system and the licence they acquired is no longer valid, and then, the they must do a recovery, because the OEM product key is not going to work.

This is why I like to be sure this script can be used to restore the OEM Product Key in a legal way, only in the same system OEM, to avoid a recovery.
April 14th, 2015 12:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics