I found a Visual BASIC code for extracting installed Microsoft products, (including Operating Systems), key from the registry. After hours of conversion, this is what I came up with:
$a=RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")
If $a<>"" Then
$xpkey=MSDecode($a, "-")
ClipPut($xpkey)
InputBox("Windows OS Product Key", "The installed Windows Operating System Product Key has been copied to the clipboard and is:", $xpkey)
Else
MsgBox(0,"ERROR","No