Jump to content

Recommended Posts

Posted

@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 

  • Moderators
Posted

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!

Posted (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 by Earthshine

My resources are limited. You must ask the right questions

 

Posted

@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

Posted (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 by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Posted (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

 

#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 by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Posted

@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

 

Posted

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

 

Posted (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 by DigDeep
Posted (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 by benners

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...