Sign in to follow this  
Followers 0
blender

How to obtain the name of a Reg Key?

7 posts in this topic

Hi, all

I need to obtain the name of a reg key for an application under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall". However, name of the regkey is random everytime I install the program. The only thing consistant is the value of a sub regkey "InstallLocation" under that regkey and the value is known. (So the value of the regkey "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{xxxxx}\InstallLocation" is known for me. But {xxxx} is random)

Is there a way for me to obtain the name of the regkey ({xxxx}) by only knowing the value of its sub-regkey? I tried RegEnumKey, but it doesn't seem to work in my case.

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, all

I need to obtain the name of a reg key for an application under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall". However, name of the regkey is random everytime I install the program. The only thing consistant is the value of a sub regkey "InstallLocation" under that regkey and the value is known. (So the value of the regkey "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{xxxxx}\InstallLocation" is known for me. But {xxxx} is random)

Is there a way for me to obtain the name of the regkey ({xxxx}) by only knowing the value of its sub-regkey? I tried RegEnumKey, but it doesn't seem to work in my case.

Thanks

Maybe this way if you have clue about the random one:

For $i= 1 to 100
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
    If @error <> 0 then ExitLoop
    If StringInStr ( $var, "xxxx" ) Then
        MsgBox(4096, "SubKey #" & $i & " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall: ", $var)
    EndIf
Next

Otherwise:

Put the $var values into array and then loop through the subregs to get the value from the InstallLocation. When it is found then use the RegEnumKey to get the value of the desired regkey.

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Maybe this way if you have clue about the random one:

For $i= 1 to 100
    $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
    If @error <> 0 then ExitLoop
    If StringInStr ( $var, "xxxx" ) Then
        MsgBox(4096, "SubKey #" & $i & " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall: ", $var)
    EndIf
Next

Otherwise:

Put the $var values into array and then loop through the subregs to get the value from the InstallLocation. When it is found then use the RegEnumKey to get the value of the desired regkey.

Thank you very much. I solved the problem.

I have another stupid question now. How do I break out of a loop? Break function looks different from it's in other languages.

Share this post


Link to post
Share on other sites

Thank you very much. I solved the problem.

I have another stupid question now. How do I break out of a loop? Break function looks different from it's in other languages.

Its in the helpfile, just like everything else.

http://www.autoitscript.com/autoit3/docs/k...ontinueLoop.htm

http://www.autoitscript.com/autoit3/docs/k...ds/ExitLoop.htm

Share this post


Link to post
Share on other sites

One of the really good looking birds on this forum posted a recursive registry search fuction: _RegSearch()

:D

PsaltyDS ! Thanks for sharing and mentioning this function. It is very useful for me :P


Be Green Now or Never (BGNN)!

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