MS Office Product Key #

(imported topic written by Aria91)

Hi All,

Is it possible to get Ms Office product Key# via BigFix report from WinXP\Vista and MAC?

Thanks in advance,

Aria

(imported comment written by BenKus)

Hi Aria,

See here:

http://forum.bigfix.com/viewtopic.php?id=62

Ben

(imported comment written by kevin_tang91)

Hi Aria,

You may want to use the following action script to write the key into registry, the use the properities to get them back.

// enter your action script here

delete __createfile

createfile until gotit

CONST HKEY_LOCAL_MACHINE = &H80000002

CONST SEARCH_KEY = “DigitalProductID”

Dim arrSubKeys(5,1)

Dim foundKeys

Dim iValues, arrDPID

foundKeys = Array()

iValues = Array()

arrSubKeys(0,0) = “{“Windows” as hexadecimal}”

arrSubKeys(0,1) = “SOFTWARE\Microsoft\Windows NT\CurrentVersion”

arrSubKeys(1,0) = “{“Office XP” as hexadecimal}”

arrSubKeys(1,1) = “SOFTWARE\Microsoft\Office\10.0\Registration”

arrSubKeys(2,0) = “{“Office 2007” as hexadecimal}”

arrSubKeys(2,1) = “SOFTWARE\Microsoft\Office\12.0\Registration”

arrSubKeys(3,0) = “{“Office 2003” as hexadecimal}”

arrSubKeys(3,1) = “SOFTWARE\Microsoft\Office\11.0\Registration{{90110804-6000-11D3-8CFE-0150048383C9}”

arrSubKeys(4,0) = “{“Project 2003” as hexadecimal}”

arrSubKeys(4,1) = “SOFTWARE\Microsoft\Office\11.0\Registration{{903B0804-6000-11D3-8CFE-0150048383C9}”

arrSubKeys(5,0) = “{“Visio 2003” as hexadecimal}”

arrSubKeys(5,1) = “SOFTWARE\Microsoft\Office\11.0\Registration{{90510804-6000-11D3-8CFE-0150048383C9}”

’ <--------------- Open Registry Key and populate binary data into an array -------------------------->

strComputer = “.”

Set oReg=GetObject(“winmgmts:{{impersonationLevel=impersonate}!\” & strComputer & “\root\default:StdRegProv”)

For x = LBound(arrSubKeys, 1) To UBound(arrSubKeys, 1)

oReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1), SEARCH_KEY, arrDPIDBytes

If Not IsNull(arrDPIDBytes) Then

call decodeKey(arrDPIDBytes, arrSubKeys(x,0))

Else

oReg.EnumKey HKEY_LOCAL_MACHINE, arrSubKeys(x,1), arrGUIDKeys

If Not IsNull(arrGUIDKeys) Then

For Each GUIDKey In arrGUIDKeys

oReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1) & “” & GUIDKey, SEARCH_KEY, arrDPIDBytes

If Not IsNull(arrDPIDBytes) Then

call decodeKey(arrDPIDBytes, arrSubKeys(x,0))

End If

Next

End If

End If

Next

’ <----------------------------------------- Return the Product Key --------------------------------------------------->

Function decodeKey(iValues, strProduct)

Dim arrDPID

arrDPID = Array()

’ <--------------- extract bytes 52-66 of the DPID -------------------------->

For i = 52 to 66

ReDim Preserve arrDPID( UBound(arrDPID) + 1 )

arrDPID( UBound(arrDPID) ) = iValues(i)

Next

’ <--------------- Create an array to hold the valid characters for a microsoft Product Key -------------------------->

Dim arrChars

arrChars = 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”)

’ <--------------- The clever bit !!! (decode the base24 encoded binary data)-------------------------->

For i = 24 To 0 Step -1

k = 0

For j = 14 To 0 Step -1

k = k * 256 Xor arrDPID(j)

arrDPID(j) = Int(k / 24)

k = k Mod 24

Next

strProductKey = arrChars(k) & strProductKey

If i Mod 5 = 0 And i 0 Then strProductKey = “-” & strProductKey

Next

ReDim Preserve foundKeys( UBound(foundKeys) + 1 )

foundKeys( UBound(foundKeys) ) = strProductKey

strKey = UBound(foundKeys)

Set wshShell=CreateObject(“wscript.shell”)

wshShell.RegWrite “HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\Settings\Client\uSerial” & strProduct, foundKeys(strKey), “REG_SZ”

Set wshShell = Nothing

End Function

WScript.Quit

gotit

copy __createfile serial.vbs

script serial.vbs

delete serial.vbs

delete __createfile

delete __appendfile

appendfile {concatenation “%0d%0a” of (“Windows Registry Editor Version 5.00”;"";"

HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\Settings\Client\uSerial

“; ((”%22" & name of it as string & “%22 = %22” & it as string as hexadecimal & “%22”) of values of keys “HKEY_LOCAL_MACHINE\SOFTWARE\BigFix\EnterpriseClient\Settings\Client\uSerial” of registry))}

copy __appendfile serial.reg

waitdetached regedit /s serial.reg

delete serial.reg

(imported comment written by bearandy)

Could it run on Win7 or Win2008??

Thanks for answer.