Jump to content

AddRemove Program Search


Zinthose
 Share

Recommended Posts

I through this together for searching for AddRemove Programs using the registry.

"Yo! U Code Noob! Just use WMI!!"

I agree however, Windows XP x64 do not install the "WMI Windows Installer Provider" by default. Thus, WMI = No Work-ie

;#include <AddRemove.au3>

    Const $SearchFor_1 = "AutoIt v3"
    Const $SearchFor_2 = "Kings Quest 8"

    MsgBox(0, "Search Results", "Search for '" & $SearchFor_1 & "' AddRemove Programs entry result: " & @CRLF & _IsInstalled($SearchFor_1))
    MsgBox(0, "Search Results", "Search for '" & $SearchFor_2 & "' AddRemove Programs entry result: " & @CRLF & _IsInstalled($SearchFor_2))

#Region #include <AddRemove.au3>
    #include-once
    
    Func _IsInstalled($DisplayName)

        Local $i = 1
        
        If @AutoItX64 Then; Adjust for x64 process
            Local $RegPath = "\Microsoft\Windows\CurrentVersion\Uninstall"
            Local $RegRoot86 = "HKLM\SOFTWARE\Wow6432Node"
            Local $RegRoot64 = "HKLM64\SOFTWARE"
        Else; Adjust for x86 process
            Local $RegPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
            Local $RegRoot86 = "HKLM"
            Local $RegRoot64 = "HKLM64"
        EndIf
        
        $IsSoftwareFound = __RegBranchSearch($RegRoot86 & $RegPath, 'DisplayName', $DisplayName);   <== Search the 32 bit registry
        
        If $IsSoftwareFound Then Return True
        If @ProcessorArch = "X86" Then Return False;    <== We are done if OS Arch is x86
        
        ;## If we are here then the current OS Arch is 64 bit and the script is running as a 32 bit process.
        
        $IsSoftwareFound = __RegBranchSearch($RegRoot64 & $RegPath, 'DisplayName', $DisplayName);   <== Search the 64 bit registry
        
        If $IsSoftwareFound Then Return True
        Return False
    EndFunc   ;==>_IsInstalled

    #Region Internal Use Only
        Func __RegBranchSearch($RegPath, $RegName, $RegValue)
            Local $RegKey, $ThisRegValue
            Local $i = 1
            
            Do
                $RegKey = RegEnumKey($RegPath, $i)
                If @error <> 0 Then ExitLoop
                
                $ThisRegValue = RegRead($RegPath & '\' & $RegKey, $RegName)
                
                If StringInStr($ThisRegValue, $RegValue) <> 0 Then Return True

                $i += 1
            Until @error <> 0
            Return False
        EndFunc
    #EndRegion Internal Use Only
#EndRegion #include <AddRemove.au3>

Enjoy :P

--- TTFN

Link to comment
Share on other sites

  • 1 year later...

I am looking for a script to select an application in Add/Remove programs and clicking uninstall!!!

Any body please help me

Hi, search the right key in this path :

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\

Then you have just to read this value name : UninstallString (with RegRead func) and you have the uninstall program :D

Edit : btw, post this kind of questions in the general help & support forum, thank you.

Cheers, FireFox.

Edited by FireFox
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...