Sign in to follow this  
Followers 0
Zinthose

AddRemove Program Search

5 posts in this topic

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

Share this post


Link to post
Share on other sites



Hi!

I tested your function in my VM with WinXP Pro x64 and it worked, so now you know it supports x64 :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Hi!

I tested your function in my VM with WinXP Pro x64 and it worked, so now you know it supports x64 :P

Wonderful! :P

I think I'll have a cookie!

Posted Image


--- TTFN

Share this post


Link to post
Share on other sites

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

Any body please help me

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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