Sign in to follow this  
Followers 0
Mecano

Search for InstallLocation in registry with GUID

3 posts in this topic

#1 ·  Posted (edited)

Hallo forum members,

Is there a way to find InstallLocation with RegRead and not knowing the GUID keys?

This is just a example, as you can see SmartFTP Client is not a key but a GUID key

; [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall{02527BE8-D797-45FC-A827-A18A3DE834D7}]
; "InstallLocation"="D:Program FilesSmartFTP Client"

In the example above the InstallLocation is D:Program Files

some users choose C:SmartFTP Client etc. so the only safe way is to read the registry, but the code I found on this forum works only if the app name is in de key

_smartFTPfolder()

;open the app folder
Func _smartFTPfolder()
  _GetInstalledPath("SmartFTP Client")
If @error Then
  $iMsgBoxAnswer = MsgBox(0, "ERROR", "not found!")
  Exit
EndIf
$openinstallfolder = (_GetInstalledPath("SmartFTP Client") )
$oShell = ObjCreate("shell.application") ; Get the Windows Shell Object
$oShell_Open = $oShell.open($openinstallfolder )
EndFunc

Func _GetInstalledPath($sProgrammName)
;Written
; @error = 1 - Not installed
;Get Installed path
Static $sInstalledPath = ""
If $sInstalledPath = "" Then
  $sInstalledPath = RegRead("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall" & $sProgrammName, "InstallLocation")
  If @error Then
   $sInstalledPath = ""
   Return SetError(1, 0, "")
  EndIf
EndIf
Return $sInstalledPath
EndFunc   ;==>_GetInstalledPath

Edit;

I found this code on the forum

$sRegKey = "HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"
$iKey = 1
While 1
    $sHold = RegEnumKey($sRegKey, $iKey)
    If @Error Then ExitLoop
    $iKey += 1
    If NOT StringRegExp($sHold, "^{[-[:xdigit:]]+}$") Then ContinueLoop;;  We only want the ones that use a Guid.  If you want all of them then remove this line
    ;;At this point $sHold contains the ProductGUID.  If you want to actually only get those that have a ProductGUID value change "InstallLocation" to "ProductGuid" below
    $sCur_Val = RegRead($sRegKey & $sHold, "InstallLocation")
    If NOT @Error Then
        MsgBox(4096, "Result", $sHold & @CRLF & $sCur_Val, 3)
    EndIf
WEnd

but how to make a pattern/filter to find "SmartFTP Client" out of the result?

Edited by Mecano

Share this post


Link to post
Share on other sites



but how to make a pattern/filter to find "SmartFTP Client" out of the result?

Try to check the DisplayName.

example :

$sRegKey = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$iKey = 1
While 1
    $sHold = RegEnumKey($sRegKey, $iKey)
    If @Error Then ExitLoop
    $iKey += 1
IF RegRead($sRegKey & $sHold, "DisplayName") = 'Microsoft .NET Framework 4 Extended' Then
  $sCur_Val = RegRead($sRegKey & $sHold, "InstallLocation")
  If NOT @Error Then
   MsgBox(4096, "Result", $sHold & @CRLF & $sCur_Val, 3)
   ExitLoop
  EndIf
EndIf
WEnd
1 person likes this

Share this post


Link to post
Share on other sites

@JFX

:oops: Excellent solution

Works perfect

Thx a million

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