Jump to content

Check if specific program is installed / List installed programs


ptru
 Share

Recommended Posts

Well... https://www.autoitscript.com/forum/topic/123146-list-installed-programs-and-system-information/

That script still works but it is not listing everything.

I think it will only list system wide installations not including local user installations.

Also it seems to list alot of Windows related stuff... like 50 different "Visual C++ Library" entries.

I need to check if a specific programm is installed.

Mod said create a new topic so here we are.

Link to comment
Share on other sites

You can check the registry for the DisplayName example can be found here:
Note: This is based on your script being compiled as 32-bit, if you want to compile the script as 64-bit you'll need to use:
::64-bit Key
Convert HKLM64\SOFTWARE\... with HKEY_LOCAL_MACHINE\SOFTWARE\... 
:: 32-bit Key
Convert HKLM\SOFTWARE\... with HKEY_LOCAL_MACHINE\WOW6432Node\SOFTWARE\...
 

 

Link to comment
Share on other sites

Thank you, your code helped me to put together an ultimate function to check if an application is installed or not. No matter if 32bit or 64bit

This might be helpful to others.

; Search Registry and Fallback to WMI (slower)
; $is64bit = -1: search 32bit and 64bit
; $is64bit = 0: search 32bit only
; $is64bit = 1: search 64bit only
Func IsApplicationInstalled($appName, $is64bit = 0, $wmiFallback = 1)
    If $is64bit = -1 Then
        If IsApplicationInstalled($appName, 0, 0) = 1 Then
            Return 1
        EndIf
        $is64bit = 1
    EndIf

    $regList = GetRegUninstallList($is64bit)

    If $regList = -1 Then Return -1
    For $key in $regList
        if StringLower($key) = StringLower($appName) Then
            Return 1
        EndIf
    Next

    If $wmiFallback = 1 Then
        $wmiList = GetWMIList()

        If $wmiList = -1 Then Return -1
        For $app in $wmiList
            if StringLower($app) = StringLower($appName) Then
                Return 1
            EndIf
        Next
    EndIf

    Return 0
EndFunc

Func GetRegUninstallList($use64bit = 0)
    $sRegHive = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    If $use64bit = 1 Then
        $sRegHive = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    EndIf

    Local $aUninstall[0]
    $i = 1
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
        If @error Then ExitLoop
        _ArrayAdd($aUninstall, RegRead($sRegHive & "\" & $sRegKey, "DisplayName"))
        $i += 1
    WEnd
    Return _ArrayUnique($aUninstall)
EndFunc

Func GetWMIList()
    Local $aResult[0]

    $sPC = @ComputerName
    $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sPC & "\root\cimv2")
    $colProducts = $oWMI.ExecQuery("SELECT * FROM Win32_Product")

    If IsObj($colProducts) Then
        For $product in $colProducts
            
            _ArrayAdd($aResult, $product.Caption)
        Next
        Return _ArrayUnique($aResult)
    EndIf

    Return -1
EndFunc

 

Link to comment
Share on other sites

my 2 cents . . . compiled as 32bit - It will display both 32 and 64bit installations

#include <Array.au3>
Global $g_aSoftware[1][6] = [["Registry Hive", "DisplayName", "DisplayVersion", "Publisher", "InstallLocation"]]

;~ Current User Hive
;_ProgramsAndFeaturesList("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 32-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 64-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
_ArrayDisplay($g_aSoftware)

Func _ProgramsAndFeaturesList($_sRegHive)
    Local $sRegEnumKey, $i = 1
    While 1
        $sRegEnumKey = RegEnumKey($_sRegHive, $i)
            If @error Then ExitLoop
        If Not RegRead($_sRegHive & "\" & $sRegEnumKey, "DisplayName") = "" Then
            $x = UBound($g_aSoftware) + 1
            ReDim $g_aSoftware[$x][5]
            $x = UBound($g_aSoftware) - 1
            $g_aSoftware[$x][0] = $_sRegHive & "\" & $sRegEnumKey
            $g_aSoftware[$x][1] = RegRead($g_aSoftware[$x][0], "DisplayName")
            $g_aSoftware[$x][2] = RegRead($g_aSoftware[$x][0], "DisplayVersion")
            $g_aSoftware[$x][3] = RegRead($g_aSoftware[$x][0], "Publisher")
            $g_aSoftware[$x][4] = RegRead($g_aSoftware[$x][0], "InstallLocation")
        EndIf
        $i += 1
    WEnd
EndFunc

 

Edited by Shark007
Link to comment
Share on other sites

@Shark007 Believe this is one of my earlier scripts, found that you can  add the following to the top of the script to compile in either 32-bit or 64-bit.  The reason I also use HKCU is because some products like Chrome can be installed in the users context, if they install it themselves without admin rights.  Pain for administrators to remove when deploying custom Chrome versions as you have to remove the software using the users credentials.

#include <Array.au3>
;~ Check if script compiled as 64-bit and change $g_sHKLMxx variable
Global $g_sHKLM32 = @AutoItX64 ? "HKLM\SOFTWARE\WOW6432Node" : "HKLM\SOFTWARE"
Global $g_sHKLM64 = @AutoItX64 ? "HKLM\SOFTWARE" : "HKLM64\SOFTWARE"

Global $g_aSoftware[1][6] = [["Registry Hive", "DisplayName", "DisplayVersion", "Publisher", "InstallLocation"]]

;~ Current User Hive
_ProgramsAndFeaturesList("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 32-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList($g_sHKLM32 & "\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 64-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList($g_sHKLM64 & "\Microsoft\Windows\CurrentVersion\Uninstall")
_ArrayDisplay($g_aSoftware)

Func _ProgramsAndFeaturesList($_sRegHive)
    Local $sRegEnumKey, $i = 1
    While 1
        $sRegEnumKey = RegEnumKey($_sRegHive, $i)
            If @error Then ExitLoop
        If Not RegRead($_sRegHive & "\" & $sRegEnumKey, "DisplayName") = "" Then
            $x = UBound($g_aSoftware) + 1
            ReDim $g_aSoftware[$x][5]
            $x = UBound($g_aSoftware) - 1
            $g_aSoftware[$x][0] = $_sRegHive & "\" & $sRegEnumKey
            $g_aSoftware[$x][1] = RegRead($g_aSoftware[$x][0], "DisplayName")
            $g_aSoftware[$x][2] = RegRead($g_aSoftware[$x][0], "DisplayVersion")
            $g_aSoftware[$x][3] = RegRead($g_aSoftware[$x][0], "Publisher")
            $g_aSoftware[$x][4] = RegRead($g_aSoftware[$x][0], "InstallLocation")
        EndIf
        $i += 1
    WEnd
EndFunc

 

Link to comment
Share on other sites

47 minutes ago, Subz said:

@Shark007 Believe this is one of my earlier scripts <snip>

Since I am a fan of your work ... Thanks!     :)

I hadnt noted the source, but I did modify it to display installed codecs and their Merits

#AutoIt3Wrapper_UseX64=y

#include <Array.au3>

Global $g_aCodec[1][5]

_CodecList("HKCR\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance")

_ArraySort($g_aCodec, 1, 0, 0, 4)
_ArrayDisplay($g_aCodec, '64Bit Installed Codecs', "|1:", "64", "", 'Registry Path|Display Name|fullpath\filename|CLSID|MERIT') ;  |1:

Func _CodecList($_sRegHive)   ;==> list current codecs
    Local $sRegEnumKey, $i = 1
    While 1
        $sRegEnumKey = RegEnumKey($_sRegHive, $i)
        If @error Then ExitLoop
        If Not RegRead($_sRegHive & "\" & $sRegEnumKey, "CLSID") = "" Then
            $x = UBound($g_aCodec) + 1
            ReDim $g_aCodec[$x][5]
            $x = UBound($g_aCodec) - 1
            $g_aCodec[$x][0] = $_sRegHive & "\" & $sRegEnumKey
            $g_aCodec[$x][1] = RegRead($g_aCodec[$x][0], "FriendlyName")
            $g_aCodec[$x][3] = RegRead($g_aCodec[$x][0], "CLSID")
            $g_aCodec[$x][2] = RegRead('HKCR\CLSID\' & $g_aCodec[$x][3] & "\InprocServer32", "")
            $g_aCodec[$x][4] = StringTrimRight(StringReverse(StringLeft(RegRead($g_aCodec[$x][0], "FilterData"), 15)), 9)
        EndIf
        $i += 1
    WEnd
EndFunc   ;==>  list current codecs

 

Edited by Shark007
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...