const HKEY_LOCAL_MACHINE = &H80000002
MyRegKeyName = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
MyRegKeyValue = "DigitalProductId"
function GetProductKey
dim pValues()
Set MyBinaryReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
MyBinaryReg.GetBinaryValue HKEY_LOCAL_MACHINE,MyRegKeyName,MyRegKeyValue,pValues
Dim sArrayPID
sArrayPID = Array()
For i = 52 to 66
ReDim Preserve sArrayPID( UBound(sArrayPID) + 1 )
sArrayPID(UBound(sArrayPID)) = pValues(i)
Next
Dim ArrayProductKeyChars
ArrayProductKeyChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")
For i = 24 To 0 Step -1
k = 0
For j = 14 To 0 Step -1
k = k * 256 Xor sArrayPID(j)
sArrayPID(j) = Int(k / 24)
k = k Mod 24
Next
MyProductKey = ArrayProductKeyChars(k) & MyProductKey
if i Mod 5 = 0 And i <> 0 Then MyProductKey = "-" & MyProductKey
Next
GetProductKey = MyProductKey
end function
function GetOSVersion
Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
for each System in SystemSet
GetOSVersion = Trim(System.Caption) & ": (" & System.Version & ")"
next
end function
wscript.echo GetOSVersion & vbCrLf & "Product_Key : " & GetProductKey