Find out GUID from Classes/Installer by ProductCode with VBScript

 

We all know by now that the MSI information is stored in

  • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\ – For 32bit apps
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ – For 64bit Apps

In here you can find all the information needed about an MSI, for example the Product Name, Version, where it was installed from, uninstall string, and many more.

But an MSI is also registered in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\.

In this registry you can find extra settings like AuthorizedLUAApp, Language, SourceList and so much more.

Funny enough, you can change the app name from HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\ and this will appear different in Add/Remove Programs.

Even if you haven’t changed the DisplayName in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\ this will appear different.

 

But, as you can see, in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\, it doesn’t appear that those are Product Codes right? If you look into your MSI, you will not find that string. So what is it then?

Well…it is actually your MSI Product Code..only changed.

The way this GUID is stored into HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\ is:

  • First 8 digits are reversed
  • Next 4 digits are reversed
  • Next 4 digits are reversed
  • The next 16 digits are reversed two by two

For example, let’s say i have the MSI Product Code {6732E1E0-6629-4B92-A25F-40377D162D15}, this will be placed in Classes\Installer as 0E1E2376926629B42AF50473D761D251.

But don’t worry, this key is not dynamic on each machine, it remains the same everywhere you install the MSI.

If you want to change something in this key, you could write a script that point to the exact key, for example HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\0E1E2376926629B42AF50473D761D251

 

But what if we want something more dynamic? Well i’ve developed a VBScript that returns the GUID based on the ProductCode. Code is as follows:

 


Function ProdReg (ProductCode)

arr = Split(ProductCode,"-")
arr1 = rev(arr(0))
arr2 = rev(arr(1))
arr3 = rev(arr(2))
arr4 = revby2(arr(3))
arr5 = revby2(arr(4))

prodreg = arr1&arr2&arr3&arr4&arr5
End Function

Function rev(s)
Dim p
For p = Len(s) To 1 Step -1
rev = rev & Mid(s, p, 1)
Next
End Function

Function revby2(str)
for x=1 to len(str)-1 step 2
v = rev(Mid(str,x,2))
revby2 = revby2 & v
next
End Function

Sharing is caring!

Leave a comment

Your email address will not be published. Required fields are marked *

12 + 15 =