Jump to content
Sign in to follow this  
blender

How to obtain the name of a Reg Key?

Recommended Posts

blender

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
lsakizada

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
blender

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
weaponx

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
PsaltyDS

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

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
lsakizada

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.