WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Encryption

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Windows Install CDKEY

 Keywords:  CD-KEY

This code will find the original install CDKey used for most Microsoft Products installed on 2000 and XP machines. This particular one is for the Windows key!


#DefineFunction Dec2Hex(Dec)
IsZero=@TRUE
str="0123456789ABCDEF"
hex=""

for x=7 to 0 by -1
nibble= (dec >> (x*4)) & 15
if nibble==0 && IsZero==@TRUE then continue
IsZero=@FALSE
hex=strcat(hex,Strsub(str,nibble+1,1))
next
return(hex)
#EndFunction

#DefineFunction Hex2Dec(hex)
str="0123456789ABCDEF"
hex=StrTrim(StrUpper(hex))
hexlen=StrLen(hex)
dec=0
for x=1 to hexlen
dec=(dec*16) + StrIndex(str,strsub(hex,x,1),0,@fwdscan) -1
next
return(dec)
#EndFunction

reghandle=RegOpenKeyEx(@REGMACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","READ",0,0)
tmp=RegQueryBin(reghandle,"[DigitalProductId]")
RegCloseKey(reghandle)
HexBuf=Arrayize(tmp," ")
lbound=0
ubound=ArrInfo(HexBuf,1) -1
StartOffset=52
EndOffset=67
Digits=ArrDimension(24)
Digits [0] = "B" 
Digits [1] = "C" 
Digits [2] = "D"
Digits [3] = "F"
Digits [4] = "G"
Digits [5] = "H" 
Digits [6] = "J" 
Digits [7] = "K"
Digits [8] = "M" 
Digits [9] = "P" 
Digits [10] = "Q" 
Digits [11] = "R"
Digits [12] = "T" 
Digits [13] = "V" 
Digits [14] = "W" 
Digits [15] = "X"
Digits [16] = "Y"
Digits [17] = "2" 
Digits [18] = "3"
Digits [19] = "4"
Digits [20] = "6"
Digits [21] = "7" 
Digits [22] = "8"
Digits [23] = "9"

dLen=29
sLen=15

HexDigitalPID=ArrDimension(16) ;15
Des=ArrDimension(30)
tmp2=""
for i=StartOffset to EndOffset
tempxyz= HexBuf[i] ;<<<<<<<<<<<<<
HexDigitalPID [i-StartOffset] = tempxyz
tmp2=tmp2 : " " : Hex2Dec (HexDigitalPID[i-StartOffset] )
next

KEYSTRING=""
for i=dLen-1 to 0 by -1
if ((i + 1) mod 6) == 0 
Des [i] = "-"
KEYSTRING =KEYSTRING : "-"
else
HN = 0
For N = (sLen-1) to 0 by -1
Value = ( (HN *2**8 ) | Hex2Dec(HexDigitalPID [N]))
HexDigitalPID [N] = Dec2Hex(Value / 24 ) ;Value \ 24
HN = (Value mod 24)

next
Des[i] = Digits[HN]
KEYSTRING =KEYSTRING : Digits[HN]
endif
next

KeyString2 = ""
For xx = 29 to 1 by -1
ThisLetter = StrSub(KeyString, xx, 1)
KeyString2 = StrCat(KeyString2,ThisLetter)
Next xx

Message("Original Windows CD Key was:",KeyString2)
exit


Article ID:   W17252
File Created: 2007:07:03:14:29:00
Last Updated: 2007:07:03:14:29:00