Sign in to follow this  
Followers 0
Chimaera

Collecting uninstallers regex issue (i think)

1 post in this topic

#1 ·  Posted (edited)

I had some help from DXRW4E sometime ago and this is the code that he gave me to use

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_Icon=compile\chimaera_red.ico
#AutoIt3Wrapper_Outfile=Registry Uninstall Search.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <_RegEnumKeyEx.au3>
#include <Array.au3>

Global Const $sPatternGUID = "\{?(.)(.)(.)(.)(.)(.)(.)(.)-?(.)(.)(.)(.)-?(.)(.)(.)(.)-?(.)(.)(.)(.)-?(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)\}?"
Global Const $sComponentIdPattern  = "$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"
;;Global Const $scGUIDPattern = "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)"
Global Const $sGUIDPattern  = "{$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}"

;~ _GetCompressedGUID('{0A7D6F3C-F2AB-48ED-BE23-99791BFF87D6}')

; #FUNCTION# =======================================================================================================================================================
; Name...........: _GetCompressedGUID
; Description ...: Connvert String GUID to String Compressed GUID
; Syntax.........: _GetCompressedGUID($sGUID[, $iFlags])
; Parameters ....: $sGUID - String GUID
;                  $iFlags - Optional, (Default = 0), if $iFlags $sGUID must be contain String Compressed GUID
; Return values .: String Product Properties, and set error
; Author ........: DXRW4E
; Modified.......:
; Remarks .......:
; Link ..........:
; Example .......:
; Note ..........:
; ==================================================================================================================================================================
Func _GetCompressedGUID($sGUID, $iFlags = 0)
    Return StringRegExpReplace($sGUID, $sPatternGUID, ($iFlags ? $sGUIDPattern : $sComponentIdPattern))
EndFunc


Global $aUninstallCheck, $aKeyList[1] = [0], $aMsiPath, $sMsiPath = "HKLM\SOFTWARE\Classes\Installer\Products\"
Global $aRegPath = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\|' & _
        'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\|' & _
        'HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\|' & _
        'HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\|' & _
        'HKCU64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'
$aRegPath = StringSplit($aRegPath, "|")

For $i = 1 To $aRegPath[0]
    $aRegEnumKeyEx = _RegEnumKeyEx($aRegPath[$i], 256, "*","*") ;*UninstallS*
    If Not @Error Then
        ReDim $aKeyList[$aKeyList[0] + $aRegEnumKeyEx[0] + 1]
        For $y = 1 To $aRegEnumKeyEx[0]
            $aKeyList[$y + $aKeyList[0]] = $aRegEnumKeyEx[$y]
        Next
        $aKeyList[0] += $aRegEnumKeyEx[0]
    EndIf
Next
If $aKeyList[0] Then
    $aUninstallCheck = _RegEnumValEx($aKeyList, 256, "*UninstallS*")
    If Not @Error Then
        For $i = 1 To $aUninstallCheck[0][0]
            $aMsiPath = StringRegExp($aUninstallCheck[$i][3], "^(?i)\h*MsiExec.exe\h+/\w\h*(\{[^\}]+\})", 1)
            If @Error then ContinueLoop
            ; Example
            ;; Example $DotNet4 = "HKLM\SOFTWARE\Classes\Installer\Products\%NetFX_Client_InstallerCode%"
            ;;RegRead($DotNet4, "AdvertiseFlags") - > %REG_DWORD%,"388"
            ;;RegRead($DotNet4, "Assignment") - > %REG_DWORD%,"1"
            ;;RegRead($DotNet4, "AuthorizedLUAApp") - > %REG_DWORD%,"0"
            ;;RegRead($DotNet4, "Clients") - > %REG_MULTI_SZ%,":"
            ;;RegRead($DotNet4, "InstanceType") - > %REG_DWORD%,"0"
            ;;RegRead($DotNet4, "Language") - > %REG_DWORD%,"0"
            ;;RegRead($DotNet4, "PackageCode") - > %REG_SZ%,"%NetFX_Client_PackageCode%"
            ;;RegRead($DotNet4, "ProductName", ,"%CoreProductName%"
            ;;RegRead($DotNet4, "Version") - > %REG_DWORD%,"67139183"
            ;;RegRead($DotNet4 & "\SourceList", "LastUsedSource") - > %REG_EXPAND_SZ%,"n;1;%SystemRoot%\Windows\Installer\"
            ;;RegRead($DotNet4 & "\SourceList", "PackageName") - > "netfx_Core_x86.msi"
            ;;RegRead($DotNet4 & "\SourceList\Media" ,"1") -> REG_SZ%";1"
            ;;RegRead($DotNet4 & "\SourceList\Net" ,"1") - > %REG_EXPAND_SZ%,"%SystemRoot%\Windows\Installer\"
            ;
            $aUninstallCheck[$i][3] &= @LF & RegRead($sMsiPath & _GetCompressedGUID($aMsiPath[0]) & "\SourceList", "PackageName")
            $aUninstallCheck[$i][3] &= @LF & StringRegExpReplace(RegRead($sMsiPath & _GetCompressedGUID($aMsiPath[0]) & "\SourceList", "LastUsedSource"), "^.*;(?=\w)", "")
        Next
    EndIf
EndIf
_ArrayDisplay($aUninstallCheck)
Local $sString = _ArrayToString($aUninstallCheck, ",", Default, Default, @CRLF) ; Make into .csv format Beta needed
;~ ConsoleWrite( $sString & @CRLF)
FileWrite(@ScriptDir & '\Logs\' & @OSVersion & ' ' & @UserName & ' ' & @MDAY & ' ' & @MON & ' ' & @MIN & ' ' & @SEC & '.csv', $sString)
MsgBox(64, 'Uninstall Capture Has Finished', @UserName & ' ' & @MDAY & ' ' & @MON & ' ' & @MIN & ' ' & @SEC & '.csv Created', 3)

It extracts the GUID so you can see the uninstaller location for the GUID but it has a small issue which i would like to correct

i think its caused by this line but im not sure

$aUninstallCheck[$i][3] &= @LF & StringRegExpReplace(RegRead($sMsiPath & _GetCompressedGUID($aMsiPath[0]) & "\SourceList", "LastUsedSource"), "^.*;(?=\w)", "")

This is what its doing

Capture.thumb.PNG.ad989220baa5efabdeda7a

It seems to be bumping the end of one of the lines down to the next line, im not sure where the piece belong either A or B but i would guess maybe B

Can anyone suggest what is causing this? Im guessing there is a special char or something it doesnt like so it starts a new line but who knows.

 

EDIT 

Another thought could it be the line length in a cell thats causing it?

I would expect the line to look like this probably

MsiExec.exe /X{0708FF30-78C0-47B0-81F0-C84604DC769C}\C:\Users\TSTECH~1\AppData\Local\Temp\NeroInstallFiles\NERO20120813151223929\applications\expresshelpchm\nero.expresshelpchm.msi

Or is it possible to add this to a new column so it doesnt happen?

 \C:\Users\TSTECH~1\AppData\Local\Temp\NeroInstallFiles\NERO20120813151223929\applications\expresshelpchm\nero.expresshelpchm.msi

Edited by Chimaera

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