storme Posted April 20, 2012 Share Posted April 20, 2012 (edited) G'day All This is a script I put together some time ago (and recently updated) that is usefull when you don't know where on a system a particular program is installed. It uses the uninstall information so won't work with programs that don't appear in the uninstall list. If the programname isn't found (i.e. no registry key of that name) then the "DisplayName" key is searched for the specified program name. If you find any errors on your system please let me know. Specify what your system is(xp/vista/7 , 32/64) and what program you were trying to find. 11/11/2013 V2.0 Update for 64 bit I finally got back to this with a 64bit OS and found my last 64bit edit didn't work. So I spent a bit of time did a bit/lot of research and came up with the code below. The script will now search through the 3 areas (hklm, hklm64 and Wow6432Node) yes I know I shouldn't have to search Wow6432Node in theory. However, I found a few programs that didn't appear in either of the other 2 so it's now included just in case. I also found that not all programs have an "uninstall" key so I've used "DisplayIcon" (which appears to be universal) to get the install location. If anyone finds a problem with this please let me know. Of course any suggestions/bug fixes are most welcome. expandcollapse popupFunc example() Local $sDisplayName ConsoleWrite(@CR & "Find : AutoItv3" & @CR) ConsoleWrite(_GetInstalledPath("AutoItv3", $sDisplayName) & " @error = " & @error & @CR) ConsoleWrite($sDisplayName & " @error = " & @error & @CR) ConsoleWrite(@CR & "Find : Adobe" & @CR) ConsoleWrite("Path = " & _GetInstalledPath("Adobe", $sDisplayName) & " @error = " & @error & @CR) ConsoleWrite("desplayname = " & $sDisplayName & " @error = " & @error & @CR) ConsoleWrite(@CR & "Find : Adobe reader" & @CR) ConsoleWrite("Path = " & _GetInstalledPath("Adobe reader", $sDisplayName) & " @error = " & @error & @CR) ConsoleWrite("desplayname = " & $sDisplayName & " @error = " & @error & @CR) EndFunc ;==>example ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetInstalledPath ; Description ...: Returns the installed path for specified program ; Syntax.........: GetInstalledPath($sProgamName) ; Parameters ....: $sProgamName - Name of program to seaach for ; - Must be exactly as it appears in the registry unless extended search is used ; $sDisplayName - Returns the "displayName" key from for the program (can be used to check you have the right program) ; $fExtendedSearchFlag - True - Search for $sProgamName in "DisplayName" Key ; $fSlidingSearch - True - Find $sProgamName anywhere in "DisplayName" Key ; False - Must be exact match ; Return values .: Success - returns the install path ; - ; Failure - 0 ; |@Error - 1 = Unable to find entry in registry ; |@Error - 2 = No "InstalledLocation" key ; Author ........: John Morrison aka Storm-E ; Remarks .......: V1.5 Added scan for $sProgamName in "DisplayName" Thanks to JFX for the idea ; : V1.6 Fix for 64bit systems ; : V2 Added support for multiple paths (32,64&Wow6432Node) for uninstall key ; : returns display name for the program (script breaking change) ; : If the Uninstall key is not found it now uses the path from "DisplayIcon" key (AutoitV3 doesn't have an Uninstall Key) ; Related .......: ; Link ..........: ; Example .......: Yes ; AutoIT link ...; http://www.autoitscript.com/forum/topic/139761-getinstalledpath-from-uninstall-key-in-registry/ ; =============================================================================================================================== Func _GetInstalledPath($sProgamName, ByRef $sDisplayName, $fExtendedSearchFlag = True, $fSlidingSearch = True) ;Using WMI : Why I diddn't use "Win32_Product" instead of the reg searching. ;http://provincialtech.com/wordpress/2012/05/15/wmi-win32_product-vs-win32_addremoveprograms/ Local $asBasePath[3] = ["hklm\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", "hklm64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", "hklm\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"] Local $sBasePath ; base for registry search Local $sCurrentKey ; Holds current key during search Local $iCurrentKeyIndex ; Index to current key Local $iErrorCode = 0 ; Store return error code Local $sInstalledPath = "" ; the found installed path $iErrorCode = 0 For $sBasePath In $asBasePath $sInstalledPath = RegRead($sBasePath & $sProgamName, "InstallLocation") If @error = -1 Then ;Unable To open "InstallLocation" key so try "DisplayIcon" ;"DisplayIcon" is usually the main EXE so should be the install path $sInstalledPath = RegRead($sBasePath & $sProgamName, "DisplayIcon") If @error = -1 Then ; Unable to find path so give-up $iErrorCode = 2 ; Path Not found $sInstalledPath = "" $sDisplayName = "" Else $sDisplayName = RegRead($sBasePath & $sProgamName, "DisplayName") $sInstalledPath = StringLeft($sInstalledPath, StringInStr($sInstalledPath, "\", 0, -1)) EndIf EndIf If $sInstalledPath <> "" Then ExitLoop EndIf Next If $sInstalledPath = "" Then ; Didn't find path by direct key request so try a search ;Key not found $iErrorCode = 0; If $fExtendedSearchFlag Then For $sBasePath In $asBasePath $iCurrentKeyIndex = 1 ;reset for next run While $fExtendedSearchFlag $sCurrentKey = RegEnumKey($sBasePath, $iCurrentKeyIndex) If @error Then ;No keys left $iErrorCode = 1 ; Path Not found ExitLoop Else $sDisplayName = RegRead($sBasePath & $sCurrentKey, "DisplayName") EndIf If ($fSlidingSearch And StringInStr($sDisplayName, $sProgamName)) Or ($sDisplayName = $sProgamName) Then ;Program name found in DisplayName $sInstalledPath = RegRead($sBasePath & $sCurrentKey , "InstallLocation") If @error Then ;Unable To open "InstallLocation" key so try "DisplayIcon" ;"DisplayIcon" is usually the main EXE so should be the install path $sInstalledPath = RegRead($sBasePath & $sCurrentKey, "DisplayIcon") If @error = -1 Then ; Unable to find path so give-up $iErrorCode = 2 ; Path Not found $sInstalledPath = "" $sDisplayName = "" Else $sInstalledPath = StringLeft($sInstalledPath, StringInStr($sInstalledPath, "\", 0, -1)) EndIf ExitLoop EndIf ExitLoop EndIf $iCurrentKeyIndex += 1 WEnd If $sInstalledPath <> "" Then ; Path found so stop looking ExitLoop EndIf Next Else $sDisplayName = "" Return SetError(1, 0, "") ; Path Not found EndIf Else Return $sInstalledPath EndIf If $sInstalledPath = "" Then ; program not found $sDisplayName = "" Return SetError($iErrorCode, 0, "") Else Return $sInstalledPath EndIf EndFunc ;==>_GetInstalledPath Have fun John Morrison aka Storm-E EDIT: Declares moved to top of function Thanks guinness Edited November 11, 2013 by storme Deathdn 1 Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
guinness Posted April 20, 2012 Share Posted April 20, 2012 Nice. I do have one point to make, try to declare variables outside of a loop as it's been found that this can increase the speed of your script. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
storme Posted April 20, 2012 Author Share Posted April 20, 2012 Nice. I do have one point to make, try to declare variables outside of a loop as it's been found that this can increase the speed of your script.Yep point taken. I've fallen into some lazy coding since uni Script fixed an updated in first postThanks! Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
guinness Posted April 20, 2012 Share Posted April 20, 2012 Yep point taken. I've fallen into some lazy coding since uni Script fixed an updated in first postThanks!I wouldn't have called you a lazy coder, this was just an oversight. Thanks for updating too. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
robinsiebler Posted June 7, 2012 Share Posted June 7, 2012 (edited) I haven't been able to find -any- program. I am only using the Display Name. Here is an example: #include <_GetInstalledPath.au3> Local $installedPath $installedPath = _GetInstalledPath("Avistar C3 Communicator™ 2.6") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $installedPath = ' & $installedPath & ' >Error code: ' & @error & @crlf) ;### Debug Console >Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "C:scriptsAutoItBuild_Auto_Installertest2.au3" @@ Debug(5) : $installedPath = >Error code: 0 +>15:05:45 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 2.043 I've tried on Win XP (32-Bit) where it is under CurrentVersion Uninstall and on Win7 (64-Bit) where it is under CurrentVersionInstaller Also, is it possible to make it do a partial match? I don't know what version will be installed and all of the programs I want to uninstall have a version number in the Display Name. Edited June 7, 2012 by robinsiebler Link to comment Share on other sites More sharing options...
storme Posted June 8, 2012 Author Share Posted June 8, 2012 Hi Robin The function already has a "partial search"...I call it a "sliding search"... ; Parameters ....: $sProgamName - Name of program to seaach for ; - Must be exactly as it appears in the registry unless extended search is used ; $fExtendedSearchFlag - True - Search for $sProgamName in "DisplayName" Key ; $fSlidingSearch - True - Find $sProgamName anywhere in "DisplayName" Key ; False - Must be exact match I don't have your program installed on my machine but this should find what you're looking for. _GetInstalledPath("Avistar C3 Communicator",true, true) Without the extra parameters the function does a basic check for a single key and if not found returns and error. $fExtendedSearchFlag - True is usfull for programs that have number entries under "uninstall". $fSlidingSearch - True allows for problems like yours where a version number is included in the display name I've got both XP-32 & Win7-64 installed here and both have "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall" On my Win 7 64 bit the "Installer" key contains totally different information. Hope that helps Let me know if you have an other problems. John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
robinsiebler Posted June 8, 2012 Share Posted June 8, 2012 Thanks! Link to comment Share on other sites More sharing options...
storme Posted March 30, 2013 Author Share Posted March 30, 2013 Latest version...The test code I used back in June last year was telling me lies... there is a difference between 32 & 64 bit... sigh sorrySo a minor change was in order to make it work on 32 & 64Bit systems and here it is. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=1.6.0.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #AutoIt3Wrapper_Versioning=v #AutoIt3Wrapper_Versioning_Parameters=/Comments v%fileversion%: #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#AutoIt3Wrapper_Run_Debug_Mode=y Func example() Local $installedPath $installedPath = _GetInstalledPath("Adobe Reader") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $installedPath = ' & $installedPath & ' >Error code: ' & @error & @crlf) ;### Debug Console $installedPath = _GetInstalledPath("KB2482017") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $installedPath = ' & $installedPath & ' >Error code: ' & @error & @crlf) ;### Debug Console $installedPath = _GetInstalledPath("EASEUS Todo Backup Free") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $installedPath = ' & $installedPath & ' >Error code: ' & @error & @crlf) ;### Debug Console $installedPath = _GetInstalledPath("InCD!UninstallKey") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $installedPath = ' & $installedPath & ' >Error code: ' & @error & @crlf) ;### Debug Console EndFunc ;==>example ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetInstalledPath ; Description ...: Returns the installed path for specified program ; Syntax.........: GetInstalledPath($sProgamName) ; Parameters ....: $sProgamName - Name of program to seaach for ; - Must be exactly as it appears in the registry unless extended search is used ; $fExtendedSearchFlag - True - Search for $sProgamName in "DisplayName" Key ; $fSlidingSearch - True - Find $sProgamName anywhere in "DisplayName" Key ; False - Must be exact match ; Return values .: Success - returns the install path ; Failure - 0 ; |@Error - 1 = Unable to find entry in registry ; |@Error - 2 = No "InstalledLocation" key ; Author ........: John Morrison aka Storm-E ; Remarks .......: V1.5 Added scan for $sProgamName in "DisplayName" Thanks to JFX for the idea ; : V1.6 Fix for 64bit systems ; Related .......: ; Link ..........: ; Example .......: ; AutoIT link ...; http://www.autoitscript.com/forum/topic/139761-getinstalledpath-from-uninstall-key-in-registry/ ; =============================================================================================================================== Func _GetInstalledPath($sProgamName, $fExtendedSearchFlag = True, $fSlidingSearch = True) Local $i64Bit = '' If @OSArch = 'X64' Then $i64Bit = '64' EndIf Local $sBasePath = 'HKEY_LOCAL_MACHINE' & $i64Bit & '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' Local $sCurrentKey ; Holds current key during search Local $iCurrentKeyIndex ; Index to current key Local $sInstalledPath = RegRead($sBasePath & $sProgamName, "InstallLocation") If @error Then If @error = -1 Then ;Unable To open InstallLocation so unable to find path Return SetError(2, 0, "") ; Path Not found EndIf ;Key not found If $fExtendedSearchFlag Then $iCurrentKeyIndex = 1 While 1 $sCurrentKey = RegEnumKey($sBasePath, $iCurrentKeyIndex) If @error Then ;No keys left Return SetError(1, 0, "") ; Path Not found EndIf If ($fSlidingSearch And StringInStr(RegRead($sBasePath & $sCurrentKey, "DisplayName"), $sProgamName)) Or (RegRead($sBasePath & $sCurrentKey, "DisplayName") = $sProgamName) Then ;Program name found in DisplayName $sInstalledPath = RegRead($sBasePath & $sCurrentKey, "InstallLocation") If @error Then ;Unable To open InstallLocation so unable to find path Return SetError(2, 0, "") ; Path Not found EndIf ExitLoop EndIf $iCurrentKeyIndex += 1 WEnd Else Return SetError(1, 0, "") ; Path Not found EndIf EndIf Return $sInstalledPath EndFunc ;==>_GetInstalledPath Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
SteveP Posted June 4, 2013 Share Posted June 4, 2013 I think it would be a good idea to search both 32 and 64 bit keys on a 64 bit system as you probably have both types of software installed. I did something similar to your script for getting the DisplayVersion of an installed software package. expandcollapse popup; _GetDisplayVersion searches the registry for the uninstall information for $ProgramName and returns the $Version number ; IN: ; $ProgramName Part or all of the DisplayName in Uninstall REG Key ; OUT: ; int It returns the value of DisplayVersion Func _GetDisplayVersion($ProgramName) Local $i = 1, $Software = '', $DisplayName = '', $Version = '', $Key = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' While 1 ;Enumerate the Uninstall keys $Software = RegEnumKey($Key, $i) If @error <> 0 Then ExitLoop ;Check the value of the DisplayName key $DisplayName = RegRead($Key & $Software, 'DisplayName') If StringInStr($DisplayName, $ProgramName) Then ;Get the value of DisplayVersion $Version = RegRead($Key & $Software, 'DisplayVersion') EndIf $i += 1 WEnd If $Version = '' And @OSArch = 'X64' Then $Key = 'HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' $i = 1 While 1 ;Enumerate the Uninstall keys $Software = RegEnumKey($Key, $i) If @error <> 0 Then ExitLoop ;Check the value of the DisplayName key $DisplayName = RegRead($Key & $Software, 'DisplayName') If StringInStr($DisplayName, $ProgramName) Then ;Get the value of DisplayVersion $Version = RegRead($Key & $Software, 'DisplayVersion') EndIf $i += 1 WEnd EndIf Return $Version EndFunc ;==>_GetDisplayVersion Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 4, 2013 Moderators Share Posted June 4, 2013 I typically try to stick with WMI for something like this, usually fewer lines than enumerating the registry directly (and, as pointed out above, you don't have to worry about looking through both hives): $wbemFlagReturnImmediately = "&h10" $wbemFlagForwardOnly = "&h20" $WMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $aItems = $WMI.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $element In $aItems MsgBox(0, $element.Name & " Ver. " & $element.Version, $element.InstallLocation) Next "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
storme Posted June 7, 2013 Author Share Posted June 7, 2013 I've had a few systems with WMI failure so I've learned not to rely on WMI. Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 7, 2013 Moderators Share Posted June 7, 2013 All about experiences I have had exactly the opposite; systems where I cannot enum a remote registry. Nevertheless, there are always 100 ways to skin a cat. Very nice example on your part! "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
storme Posted June 8, 2013 Author Share Posted June 8, 2013 As I've avoided WMI in the past I don't know a lot about it. Is there a way checking if the WMI is working or dong the WMI then checking if it's failed (Without generating any error messages for the user)? I'm just thinking if the 2 were combined it'd be the best of both worlds. On ward and up ward John Morrison Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 10, 2013 Moderators Share Posted June 10, 2013 I typically use a mixture of catching any errors: Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") And double-checking that you were able to successfully obtain the object with IsObj. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
storme Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) UPDATE V2.0 Update for 64 bit I finally got back to this with a 64bit OS and found my last 64bit edit didn't work. So I spent a bit of time did a bit/lot of research and came up with this code (see first post). The script will now search through the 3 areas (hklm, hklm64 and Wow6432Node) yes I know I shouldn't have to search Wow6432Node in theory. However, I found a few programs that didn't appear in either of the other 2 so it's now included just in case. I also found that not all programs have an "uninstall" key so I've used "DisplayIcon" (which appears to be universal) to get the install location. If anyone finds a problem with this please let me know. It works on Windows 7 32 & 64 and should work on other platforms but as yet is untested. Let me know if you have any problems on a particular platform. Onward and upward John Morrison P.S I did look into changing over to WMI but when I started searched to find out if there were any pitfalls I found this. http://provincialtech.com/wordpress/2012/05/15/wmi-win32_product-vs-win32_addremoveprograms/ I didn't have time to check if it affects AutoIt but my guess is "yes of course it would". However, I don't use WMI as I'd has too many problems with it in the past. Edited November 11, 2013 by storme Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
marshal Posted November 11, 2013 Share Posted November 11, 2013 Hi Storme.... somehow I'm not able to get it to work under Windows 7 32Bit. I'm not sure if I'm doing something wrong but even if I compile the script it won't execute. Link to comment Share on other sites More sharing options...
mLipok Posted November 12, 2013 Share Posted November 12, 2013 (edited) Win7Pro 64Bit Find : AutoItv3 C:Program Files (x86)AutoIt3 @error = 0 AutoIt v3.3.8.1 @error = 0 Find : Adobe Path = C:WindowsSysWOW64MacromedFlash @error = 0 desplayname = Adobe Flash Player 11 ActiveX @error = 0 Find : Adobe reader Path = @error = 1 desplayname = @error = 0 EDIT: despite noticed the problem, very nice Edited November 12, 2013 by mlipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted November 12, 2013 Share Posted November 12, 2013 (edited) Why do not you use HKEY_CURRENT_USER example: [HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionUninstallGoogle Chrome] EDIT: Have you ever wondered about the search programs in this registry key? [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths] [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionApp Paths] Edited November 12, 2013 by mlipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted November 12, 2013 Share Posted November 12, 2013 Find : Adobe reader Path = @error = 1 desplayname = @error = 0 It seems that this problem is only with Acrobat Reader 9.x (Probably the installation package does not use these registry keys) But it seems that newer versions of already work properly. Find : Adobe reader Path = C:Program FilesAdobeReader 10.0Reader @error = 0 desplayname = Adobe Reader X (10.1.6) - Polish @error = 0 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
storme Posted November 13, 2013 Author Share Posted November 13, 2013 It seems that this problem is only with Acrobat Reader 9.x (Probably the installation package does not use these registry keys) But it seems that newer versions of already work properly. I haven't got a computer with V9 installed on it. But it could be simply that the example is looking for "Adobe reader" not "Acrobat Reader". If V9 doesn't have "Adobe reader" in the key or the display name it won't be found. Let me know if my guess is right. Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now