Registry Key extraction and migration

E

ed

Hi I want to write a tool to do the following:
1. extract and display registry keys under abritrary starting point,
for example:
source are: HKey_Local_machine\software\old_lcoation or
HKey_current_user\software\XXX\YYY

a) then, I can specify where the Keys can be copied and compare the
new location to the new location. For example: destination are:
HKEY_local_mahcine\software\New_location.

b) if the keys are not there flags error message

how canI do that?
 
L

Larry Bates

Ed,

Take a look at _winreg module. It supports
everything you are looking for. You were not
perfectly clear on what keys/values you needed
so the code below is a guess...

Larry Bates
Syscon, Inc.


import _winreg
regkey='software\old_lcoation' # Copied your spelling
value_name="XXX"
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regkey)
value=_winreg.QueryValueEx(key, value_name)[0]

new_value="YYY"
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regkey, 0,
_winreg.KEY_SET_VALUE)
_winreg.SetValueEx(key, value_name, 0, _winreg.REG_SZ, new_value)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top