#176180 - 2007-05-10 05:14 PM
Copy registry key
|
skumflum
Lurker
Registered: 2007-05-10
Posts: 2
|
Hi’
I’m about to create an addition to a login script. I need to copy an entire registry key tree from HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER.
To be more specific : • HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}\Version
TO
• HKEY_CURRENT_USER\Software\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}\Locale
I’m a KIX newbie. Can somebody point me in the right direction?
Regards Søren
|
|
Top
|
|
|
|
#176192 - 2007-05-11 12:50 AM
Re: Copy registry key
[Re: Mart]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
|
Actually, read/writevalue commands are only part of the story. If you want to copy an entire subtree, you will need to play with the EnumKey and EnumValue commands as well.
EnumKey is placed in a loop (as per the example in the manual) to "discover" each subkey path. For each value returned by EnumKey, you'll need to run an inner loop using EnumValue functions - this will return the name of each value in the key. Then you'll need to use ReadValue to read the data, and ReadType to determine the registry value type - you'll need this information for WriteValue. Now that you have the key, value, data, and type, you can translate the Key path from HKLM to HKCU as you need, and then use WriteValue with the key, value, data, and type arguments. The inner loop continues until an error occurs when there are no more values, and the outer loop searches for the next subkey. This process repeats until all subkeys and values are found and copied. Of course, you need to consider recursion - processing the subkeys within subkeys.
As you can see, this is not a trivial process. There are several UDFs that search the registry, such as this one from Howard, which also references on by Jens.
Hope this helps..
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#176202 - 2007-05-11 09:53 AM
Re: Copy registry key
[Re: Arend_]
|
skumflum
Lurker
Registered: 2007-05-10
Posts: 2
|
I was worried that the ”tree” stuff was difficult.
I’ll try to look at one from Howard :-)
Thanks
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|