MSIEXEC -Embedding

ⅰ亾dé卋堺 提交于 2019-12-02 17:14:45

问题


Good afternoon,

I need some help from some Microsoft gurus that deal with windows installer?

I am trying to monitor msiexec utilising the debug keys within windows on a virtual machine and trying to fully understand how Msiexec is fully parsing command lines.

I have set up the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\msiexec.exe

Redirected into a sample application to monitor command line parsed.

I have come across numerous examples from removing applications and installing for example C++ redistributable's.

I understand the standard normal command line but cannot get to understand how the -embedding switch is utilised.

The syntax is generally -Embedding 2FD6A2BDD8FE7E3EE9AD31C2970C272C A

I have tried searching through the registry and no avail for semi Guid?

A - seems to signify a install. C - seems to signify a removal.

Anyone know of good documentation that i can look at to understand what is happening, this is on the back of another question i asked a few days ago which i feel has been answered.

External handler for msiexec MsiSetExternalUI


回答1:


How are the guids rearranged

They are what Microsoft calls "compressed". Quite why they bother is a mystery but...whatever. I also seen them referred to as "Darwinian transformed GUIDs." Here's a script that you can feed GUIDs to to get a compressed one and vice-versa:

'strCode    = "{87E21645-7A8E-454D-B899-0317F2AEE9B9}"
strMungedCode   = "4659EEA429F218A4CAEDA156497418B7"

'Call MungeProductCode(strCode, strMungedCode)
'WScript.Echo strCode & " munged becomes " & strMungedCode

Call UnMungeProductCode(strMungedCode, strCode)
WScript.Echo strMungedCode & " unmunged becomes " & strCode

Sub MungeProductCode(ByVal strProductCode, ByRef strMungedCode)
    '// This routine munges the ProductCode into the munged format 
    '// used by various registry entries for Windows Installer
    '// For example:    {D650B8A9-C547-42D3-A7DF-0FAD0AC6E9ED}
    '//             becomes
    '//         9A8B056D745C3D247AFDF0DAA06C9EDE

    Dim arrSortOrder
    Dim strNewCode
    Dim intIndex

    arrSortOrder                = 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 munged code
    For intIndex = 0 To UBound(arrSortOrder)
        strNewCode          = strNewCode & Mid(strProductCode,arrSortOrder(intIndex),1)
    Next

    strMungedCode               = strNewCode
End Sub

Sub UnMungeProductCode(ByVal strMungedCode, ByRef strProductCode)
    '// This routine reconstructs a ProductCode from the munged format 
    '// used by various registry entries for Windows Installer
    '// For example:    9A8B056D745C3D247AFDF0DAA06C9EDE
    '//             becomes
    '//         {D650B8A9-C547-42D3-A7DF-0FAD0AC6E9ED}

    Dim arrSortOrder
    Dim intIndex
    Dim strPartTemp
    Dim strPart1
    Dim strPart2
    Dim strPart3
    Dim strPart4
    Dim strPart5

    '// Part 1
    strPartTemp             = Left(strMungedCode, 8)
    strPart1                = StrReverse(strPartTemp)

    '// Part 2
    strPartTemp             = Mid(strMungedCode, 9, 4)
    strPart2                = StrReverse(strPartTemp)

    '// Part 3
    strPartTemp             = Mid(strMungedCode, 13, 4)
    '// Excuse me! May I borrow these variables for a moment?
    strPart3                = Left(strPartTemp, 2)
    strPart4                = Right(strPartTemp, 2)
    strPart3                = StrReverse(strPart4) & StrReverse(strPart3)

    '// Now deal with part 4 properly
    strPartTemp             = Mid(strMungedCode, 17, 2)
    strPart4                = Mid(strMungedCode, 19, 2)
    strPart4                = StrReverse(strPartTemp) & StrReverse(strPart4)

    strPartTemp             = Mid(strMungedCode, 21, 12)

    arrSortOrder                = Array(2,1,4,3,6,5,8,7,10,9,12,11)
    '// Generate the product code
    For intIndex = 0 To UBound(arrSortOrder)
            strPart5            = strPart5 & Mid(strPartTemp,arrSortOrder(intIndex),1)
    Next

    strProductCode              = ""
    strProductCode              = strProductCode & "{"
    strProductCode              = strProductCode & strPart1
    strProductCode              = strProductCode & "-"
    strProductCode              = strProductCode & strPart2
    strProductCode              = strProductCode & "-"
    strProductCode              = strProductCode & strPart3
    strProductCode              = strProductCode & "-"
    strProductCode              = strProductCode & strPart4
    strProductCode              = strProductCode & "-"
    strProductCode              = strProductCode & strPart5
    strProductCode              = strProductCode & "}"
End Sub


来源:https://stackoverflow.com/questions/48869988/msiexec-embedding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!