Sign in to follow this  
Followers 0
Xenobiologist

OfficeKey displayed in InputBox

15 posts in this topic

#1 ·  Posted (edited)

HI,

I´ve written this script and now I need to know whether it runs correct with other versions installed than "Office 2003". (The one I tested and that seems to work) :geek:

When it´s correct I want to implement it in my WinInformationGUI (see signature)

Thanks for replies!

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author:        Thorsten Meger <Thorsten.Meger@gmx.de>
;
; Script Function:Read OfficeKey and display in InputBox
; ----------------------------------------------------------------------------

Dim $product = ""
Dim $officeKey = ""

getOfficeKey()

Func getOfficeKey()
    Local Const $softwareKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Office'
    $line = RegRead($softwareKey, 'Displayname')
    if @error = 1 Or @error < 0 Then
        ConsoleWrite("No Office found")
    EndIf
    If StringInStr($line, "11.0") <> 0 Then
        $product = "2003"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration"
    ElseIf StringInStr($line, "10.0") <> 0 Then
        $product = "XP"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration"
    ElseIf StringInStr($line, "9.0") <> 0 Then
        $product = "2000"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration"
    EndIf
    Dim $List[1]
    Dim $i = 1
    Dim $var = RegEnumKey($officeKey, $i)
    If @error <> 0 Then Exit
    $List[$i - 1] = RegRead($officeKey & "\" & $var, "DigitalProductID")
    If $List[$i - 1] = "" Then
        MsgBox(0, "Error", "Unable to find key")
    Else
        $bin = $List[$i - 1]
        InputBox("Office " & $product & " Key", "Your Office " & $product & " product key is: ", DecodeProductKey($bin), "", -1, 100, -1, -1)
;Return ("Office " & $product & " " & DecodeProductKey($bin))
    EndIf
EndFunc ;==>getOfficeKey

Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result
    
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    
    For $i = 1 To 29 Step 2
        $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    
    For $i = $dlen - 1 To 0 Step - 1
        If Mod(($i + 1), 6) = 0 Then
            $sKey[$i] = "-"
        Else
            $hi = 0
            For $n = $slen - 1 To 0 Step - 1
                $Value = BitOR(BitShift($hi, -8), $bKey[$n])
                $bKey[$n] = Int($Value / 24)
                $hi = Mod($Value, 24)
            Next
            $sKey[$i] = $Digits[$hi + 1]
        EndIf
    Next
    For $i = 0 To 28
        $Result = $Result & $sKey[$i]
    Next
    Return $Result
EndFunc ;==>DecodeProductKey

Edit: Deleted not working version. :o

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



I can already tell you that this part won't work for earlier versions.

Local Const $softwareKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Office'
    $line = RegRead($softwareKey, 'Displayname')

I have three versions installed on my pc and 2003 is the only one in "Microsoft Office". You could enumerate the Uninstall Key then check each Displayname for "Microsoft Office". Also you might think about building a GUI with an inputbox for each version and populate each that is found on the pc.

Share this post


Link to post
Share on other sites

It does not work on my Office 2000.

This reg key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Office' does not exist and "DigitalProductID" is just "ProductID"



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

It does not work on my Office 2000.

This reg key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Office' does not exist and "DigitalProductID" is just "ProductID"

Thanks, for you replies. I changed the way to get it. Hope now it´s closer to the end.

Please tell me whether it works with Office Xp and 2000.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author:        Thorsten Meger <Thorsten.Meger@gmx.de>
;
; Script Function:Read OfficeKey and display in InputBox
; ----------------------------------------------------------------------------

Dim $product = ""
Dim $officeKey = ""
Dim $var = ""
Dim $ProductIDValue = "DigitalProductID"

$officeKey = getOfficeKey()

Dim $List[1]
Dim $i = 1
Dim $var = RegEnumKey($officeKey, $i)
If @error <> 0 Then Exit
$List[$i - 1] = RegRead($officeKey & "\" & $var, $ProductIDValue)
If $List[$i - 1] = "" Then
    MsgBox(0, "Error", "Unable to find key")
Else
    $bin = $List[$i - 1]
    InputBox("Office " & $product & " Key", "Your Office " & $product & " product key is: ", DecodeProductKey($bin), "", -1, 100, -1, -1)
;Return ("Office " & $product & " " & DecodeProductKey($bin))
EndIf

Func getOfficeKey()
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot", "Path")
    If $var <> "" Then
        $product = "2003"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration"
        Return $officeKey
    EndIf
    
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot", "Path")
    If $var <> "" Then
        $product = "XP"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration"
        Return $officeKey
    EndIf
    
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Common\InstallRoot", "Path")
    If $var <> "" Then
        $product = "2000"
        Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration"
        $ProductIDValue = "ProductID"
        Return $officeKey
    EndIf
EndFunc  ;==>getOfficeKey

Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result
    
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    
    For $i = 1 To 29 Step 2
        $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    
    For $i = $dlen - 1 To 0 Step - 1
        If Mod(($i + 1), 6) = 0 Then
            $sKey[$i] = "-"
        Else
            $hi = 0
            For $n = $slen - 1 To 0 Step - 1
                $Value = BitOR(BitShift($hi, -8), $bKey[$n])
                $bKey[$n] = Int($Value / 24)
                $hi = Mod($Value, 24)
            Next
            $sKey[$i] = $Digits[$hi + 1]
        EndIf
    Next
    For $i = 0 To 28
        $Result = $Result & $sKey[$i]
    Next
    Return $Result
EndFunc  ;==>DecodeProductKey

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

When I run it all I get is a msgbox with "Unable to find key". When I look in my registry there is nothing in "DigitalProductID" but something in "ProductID". I am running Office 2000 on Win XP Pro SP2.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

When I run it all I get is a msgbox with "Unable to find key". When I look in my registry there is nothing in "DigitalProductID" but something in "ProductID". I am running Office 2000 on Win XP Pro SP2.

Hmmh, then you have this ?

Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration"

and under registration there is another folder something like:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{90110407-6000-11D3-8CFE-0150048383C9}

and in the folder there is no DigitalProductID, but a "ProductID" , right?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hmmh, then you have this ?

Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration"

and under registration there is another folder something like:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{90110407-6000-11D3-8CFE-0150048383C9}

and in the folder there is no DigitalProductID, but a "ProductID" , right?

So long,

Mega

I have both folders but there is only a value in "ProductID"


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I have both folders but there is only a value in "ProductID"

Hmmh, and what typ of RegKey is it? REG_SZ oder REG_BINARY?

Please BigDod show me, where is the key to decode the ProductID in Office2000. ( I need path and regtype)

@All: Does it work for Office Xp?

Thank you!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hmmh, and what typ of RegKey is it? REG_SZ oder REG_BINARY?

Please BigDod show me, where is the key to decode the ProductID in Office2000. ( I need path and regtype)

@All: Does it work for Office Xp?

Thank you!

So long,

Mega

In my computer it is here

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration\ProductID"

It is REG_SZ and the value is 50158-005-0474123-02489


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

ProductID is just to identify what product and version it is. Has nothing to do with the reg number.

Share this post


Link to post
Share on other sites

ProductID is just to identify what product and version it is. Has nothing to do with the reg number.

Hi,

yes, I now. Office 2003 there is a REG_BINARY which can be decoded to the productKey. Therefore I take the DigitalProductID. (so, productID--> productKey)

But in Office2000 there seems to be no DigitalProductID(no REG_BINARY), but only a ProductID. The ProductID is a REG_SZ and so don´t know how to decode it from the 20 digits to the 25 it should be, I suppose.

The decode for Office 2003 works perfectly fine. XP I´ve got no answer and for Office2000 the problem is mentioned above. :o

Thanks!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

yes, I now. Office 2003 there is a REG_BINARY which can be decoded to the productKey. Therefore I take the DigitalProductID. (so, productID--> productKey)

But in Office2000 there seems to be no DigitalProductID(no REG_BINARY), but only a ProductID. The ProductID is a REG_SZ and so don´t know how to decode it from the 20 digits to the 25 it should be, I suppose.

The decode for Office 2003 works perfectly fine. XP I´ve got no answer and for Office2000 the problem is mentioned above. :o

Thanks!

So long,

Mega

You misunderstood what I was saying. ProductID and DigitalProductID are two totally different things. The ProductID can be used to tell exactly what office product you have (ie. pro, sb, release type, edition type, etc.) If the product has been registered then there WILL be a DigitalProductID. Like I said before I have three versions of office installed, these are the paths:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{91530409-6000-11D3-8CFE-0150048383C9}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration\{91130409-6000-11D3-8CFE-0050048383C9}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration\DigitalProductID

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

You misunderstood what I was saying. ProductID and DigitalProductID are two totally different things. The ProductID can be used to tell exactly what office product you have (ie. pro, sb, release type, edition type, etc.) If the product has been registered then there WILL be a DigitalProductID. Like I said before I have three versions of office installed, these are the paths:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{91530409-6000-11D3-8CFE-0150048383C9}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration\{91130409-6000-11D3-8CFE-0050048383C9}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration\DigitalProductID
I have got this value

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration\DigitalProductID

in my registry but there is nothing in it excapt (default) with no value.

It is also a genuine copy that I own. Are you saying that it has to be registered with Mickysoft before there is a value there.

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I have got this value

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Registration\DigitalProductID

in my registry but there is nothing in it excapt (default) with no value.

It is also a genuine copy that I own. Are you saying that it has to be registered with Mickysoft before there is a value there.

Hmmh, big_daddy do you have an answer? Does that mean, the REG_BINARY DigitalProductID appears only if the version is registered?

What about the Office XP key is it displayed correctly?

Thanks to both of you!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hmmh, big_daddy do you have an answer? Does that mean, the REG_BINARY DigitalProductID appears only if the version is registered?

What about the Office XP key is it displayed correctly?

Thanks to both of you!

So long,

Mega

Hi,

I finished my tests on Office 2003 and XP. It seems to work fine. Office 2000 doesn´t work, because there is no REG_BINARY with the DigitalProductID or ProductID. Additionally, I´ve got no Office 2000 to look for other possibilities.

Thanks, now I gonna add the function to the WinInformationGUI.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0