DigDeep Posted January 2, 2018 Share Posted January 2, 2018 @DXRW4E, I have been using the _RegEnumKeyValEx.au3 since sometime now to search for the sub-keys and it has been working fine but I am now trying to search all keys and sub-keys using the $iFlag = 0 but it does nothing for some reason. Could you please help? #include <_RegEnumKeyValEx.au3> Local $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" Local $KBname = "*KB4053577*" Local $Val = _RegEnumKeyEx($KeyPath, 0, $KBname) If $Val = True Then MsgBox(0, '', "Yes") Else MsgBox(0, '', "No") EndIf ajs Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 2, 2018 Moderators Share Posted January 2, 2018 Moved to the appropriate forum, as the Examples forum very clearly states: Quote Do not post general support questions here, instead use the AutoIt Help and Support forums. @DigDeep you have been around long enough, please pay attention to where you post in the future. "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...
Earthshine Posted January 2, 2018 Share Posted January 2, 2018 (edited) are you checking both 32 and 64 bit locations? also you should require admin on the script i would check these: \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall Edited January 2, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
DigDeep Posted January 2, 2018 Author Share Posted January 2, 2018 @JLogan3o13 thanks. @Earthshine, I am compiling with x64 but registry location will be the same for both 32 and 64 bit OS. And yes, I have declared #RequireAdmin already. Link to comment Share on other sites More sharing options...
Earthshine Posted January 2, 2018 Share Posted January 2, 2018 i don't have that udf to test with. i use RegSearch.au3 and it works great. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
DigDeep Posted January 2, 2018 Author Share Posted January 2, 2018 @Earthshine, here is the AU3 from @DXRW4E and it is able to display the correct results as Array. The only issue is that I am not able to $aKeyValList = _RegEnumKeyEx("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages", 0, "*KB4053577*") _ArrayDisplay($aKeyValList) But if I want to use this to validate like below it does not. I think I am not validating correctly. If $aKeyValList = True Then MsgBox(0, "", "Registry Key Exists") Else MsgBox(0, "", "Registry Key does not exists") EndIf Thanks for suggesting for RegSearch.au3 too. That's was the one I was also using on my other apps. So for now I am using that here. _RegEnumKeyValEx.au3 Link to comment Share on other sites More sharing options...
DXRW4E Posted January 3, 2018 Share Posted January 3, 2018 (edited) #include <_RegEnumKeyValEx.au3> Local $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $KBname = "*2d851484*" Local $aKeyPath $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") EndIf ;Or $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If IsArray($aKeyPath) Then MsgBox(0, "", "Registry Key Exists") Else MsgBox(0, "", "Registry Key does not exists") EndIf Ciao. Edited January 3, 2018 by DXRW4E Link to comment Share on other sites More sharing options...
DigDeep Posted January 3, 2018 Author Share Posted January 3, 2018 @DXRW4E, I tried both ways and it says Registry Key does not exists But the key does exist when I check in the registry... Link to comment Share on other sites More sharing options...
DXRW4E Posted January 4, 2018 Share Posted January 4, 2018 (edited) Hi DigDeep, I do not understand why so much confusion, is simple, the function does not return BOOL (TRUE or FALSE), but return Array, so to check return (TRUE or FALSE) need to use IsArray(), or use @Error for more info expandcollapse popup#RequireAdmin #include <_RegEnumKeyValEx.au3> Local $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" Local $KBname = "*Uninstall*" Local $aKeyPath $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") EndIf ;Or $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If IsArray($aKeyPath) Then MsgBox(0, "", "Registry Key Exists") Else MsgBox(0, "", "Registry Key does not exists") EndIf $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersionXXXXXX" $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") EndIf ;Or $aKeyPath = _RegEnumKeyEx($KeyPath, 0, $KBname) If IsArray($aKeyPath) Then MsgBox(0, "", "Registry Key Exists") Else MsgBox(0, "", "Registry Key does not exists") EndIf Ciao. Edited January 4, 2018 by DXRW4E Link to comment Share on other sites More sharing options...
DigDeep Posted January 4, 2018 Author Share Posted January 4, 2018 @DXRW4E , I understand. What I am saying is with the $Keypath you are showing it is working. $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" But the $KeyPath I had given example it says "Registry Key does not exist". $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" try this out taking a KB number from your machine's registry. I tried using both 0 and 1. #include <_RegEnumKeyValEx.au3> Local $KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" Local $KBname = "*4022717*" ; Take any from your machine Local $aKeyPath $aKeyPath = _RegEnumKeyEx($KeyPath, 1, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") EndIf Link to comment Share on other sites More sharing options...
benners Posted January 4, 2018 Share Posted January 4, 2018 This works for me. #include '_RegEnumKeyValEx.au3' #include <Array.au3> Local $s_HKLM = @OSArch = 'x64' ? 'HKLM64' : 'HKLM' ; check if using a 64bit machine (for redirection) Local $KeyPath = $s_HKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" ;~ Local $KBname = "*4022717*" ; Take any from your machine Local $KBname = "*4019990*" ; Take any from your machine Local $aKeyPath = _RegEnumKeyEx($KeyPath, 1, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") _ArrayDisplay($aKeyPath) EndIf Link to comment Share on other sites More sharing options...
DigDeep Posted January 4, 2018 Author Share Posted January 4, 2018 (edited) thanks @benners. So here I was doing 1 mistake. Either I can use as per above and compile as x86 which will work on both 32-bit and 64-bit Or on 64-bit machines, make it only as HKLM\.... and compile as x-64. It's working fine now. Edited January 4, 2018 by DigDeep Link to comment Share on other sites More sharing options...
benners Posted January 4, 2018 Share Posted January 4, 2018 (edited) I think if you use HKLM64 all the time, Windows sorts it out and directs to the correct hive or HKLM64 has no affect when compiled with x86. I have also tested with compiling x86 and x64 and it works no matter which you use. #include '_RegEnumKeyValEx.au3' #include <Array.au3> ;~ #AutoIt3Wrapper_UseX64=Y ; works with HKLM and $s_HKLM ;~ #AutoIt3Wrapper_UseX64=N ; doesn't work with HKLM but does with $s_HKLM Local $s_HKLM = @OSArch = 'x64' ? 'HKLM64' : 'HKLM' ; check if using a 64bit machine (for redirection) Local $KeyPath = $s_HKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" ;~ Local $KBname = "*4022717*" ; Take any from your machine Local $KBname = "*4019990*" ; Take any from your machine Local $aKeyPath = _RegEnumKeyEx($KeyPath, 1, $KBname) If @Error Then ; Return values .: Success - Return Array List (See Remarks) ; Failure - @Error ; |1 = Invalid $sFilter ; |2 = No Key-SubKey(s) Found ; |3 = Invalid $vFilter ; |4 = No Value-Name(s) Found MsgBox(0, "", "Registry Key does not exists") Else MsgBox(0, "", "Registry Key Exists") _ArrayDisplay($aKeyPath) EndIf Edited January 4, 2018 by benners 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