Jump to content

How to obtain the name of a Reg Key?


blender
 Share

Recommended Posts

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

Link to comment
Share on other sites

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)!

Link to comment
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.

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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