When working with MSI files, GUIDS can be stored in either the unpacked 38-character form eg: {4854B973-286B-4C7C-A81A-7ABC8BC07E45} or the shorter "packed" form, which requires only 32 characters - eg: 379B4584B682C7C48AA1A7CBB80CE754
There are various GUID-munger programs around, but they are one way tools. I have rudely plagiarised some of this code to create a two way converter for which the vbscript is shown below. Since there is no "copy to clipboard" native functionality in vbscript, I have added some code which leverages the MS Office Word automation object, so for this to function as intended, you must have MS Office installed (my version is Office 2007). This makes it easy to paste in either an unpacked or a packed GUID, have the converted string displayed back, and then copied to the clipboard for further use in another window. My thanks to VBScab who apparently found the original code somewhere on Appdeploy and later shared it with me.
'// Converts standard GUID to packed GUID and vice versa
'// A standard GUID requires 38 characters and contains 5 groups of hexadecimal characters separated by dashes.
'// The valid format for a standard GUID is:
'// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
'// where X is a hex digit (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
'//
'// A packed GUID is an alternative representation that allows Windows Installer to reduce the space
'// in the registry database when storing a GUID. A packed GUID requires only 32 characters.
'// Its valid format is:
'// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'// where X is a hex digit.
'//
'// This program can copy the result of the conversion process to the clipboard.
'// To do this it uses the MS Office Word automation object, so for this to work,
'// a version of MSOffice must be present. Unfortunately, VBScript does not have
'// a native method for copying variables to the clipboard.
'//
'//
'//
dim result, code, clip, objWord
result = ""
code = INPUTBOX ("Enter Product Code or Packed GUID","GUID CONVERTER")
'check if this is a GUID
If len(code) = 38 Then
If left(code,1) = "{" Then
result = GetMungedProductCode(code)
clip = msgbox(result,4097,"Press OK to copy to clipboard")
If clip = 1 then
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
With objWord
.Documents.Add
.Selection.TypeText result
.Selection.WholeStory
.Selection.Copy
.Quit 0
End With
End If
wscript.quit
End If
ElseIf len(code) = 32 Then
result = ReconstructProductCode(code)
clip = msgbox(result,4097,"Press OK to copy to clipboard")
If clip = 1 then
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
With objWord
.Documents.Add
.Selection.TypeText result
.Selection.WholeStory
.Selection.Copy
.Quit 0
End With
End If
wscript.quit
Else
msgbox "Format of string submitted does not match either a regular GUID or a packed GUID. Entries must be of the form {00010409-78E1-11D2-B60F-006097C998E7} or 904010001E872D116BF00006799C897E", 4144,"ENTRY ERROR !!!"
End If
Function GetMungedProductCode(ByVal strProductCode)
Dim arrSequence
Dim strMungedCode
Const intArraySize = 32
arrSequence = Array(9,8,7,6,5,4,3,2,14,13,12,11,19,18,17,16,22,21,24,23,27,26,29,28,31,30,33,32,35,34,37,36)
'// Generate the RegProduct Code
For intIndex = 0 To (intArraySize - 1)
strMungedCode = strMungedCode & Mid(strProductCode, arrSequence(intIndex), 1)
Next
GetMungedProductCode = strMungedCode
End Function
Function ReconstructProductCode(ByVal strMungedCode)
Dim arrSequence
Dim strProductCode
Const intArraySize = 32
strProductCode = "{"
arrSequence = Array(8,7,6,5,4,3,2,1,12,11,10,9,16,15,14,13,18,17,20,19,22,21,24,23,26,25,28,27,30,29,32,31)
'// Generate the Product Code
For intIndex = 0 to intArraySize - 1
strProductCode = strProductCode & Mid(strMungedCode,arrSequence(intIndex),1)
If intIndex = 7 Or intIndex = 11 Or intIndex = 15 Or intIndex = 19 Then
strProductCode = strProductCode & "-"
End If
Next
strProductCode = strProductCode & "}"
ReconstructProductCode = strProductCode
End Function