Reading registry export files

G

George

Hi,

I have exported some registry-keys using Regedit to a number of
..reg-files. I can open these files using any text editor. Now I wanted
to write a simple Python script to concatenate all these files to one
output file. (Please note that I'm a newbie).

However, if I do something like:

I get a lot of garbage with a lot characters which the Python shell
cannot display (it display a square instead). The above code does work
with ordinary text files.

Should I open these reg-files in a different way, or treat them
differently once read in Python?

Thanks for any help.

Kind regards, George
 
W

wittempj

It works fine for me on NT. I think it has nothing to do with Python
but with the way the file is created - what windows version are you on?
Also note the possibility the '/' - I prefer a noatation like below to
avoid ambiguity.

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
py> f = open(r"d:\test.reg")
py> r = f.read()
py> print r
REGEDIT4

I would do it like this however, then join all lists from various .reg
files:
py> f = open(r'd:\test.reg')
py> r = f.readlines()
py> print r
['REGEDIT4\n', '\n',
'[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Ole]\n', '"Enabl
eDCOM"="Y"\n',
'"DefaultLaunchPermission"=hex:01,00,04,80,64,00,00,00,80,00,00,0
0,00,00,00,00,\\\n', '
14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00
,00,01,01,00,00,00,\\\n', '
00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,
00,00,01,01,00,00,00,00,\\\n', '
00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,0
0,00,00,01,02,00,00,00,00,00,\\\n', '
05,20,00,00,00,20,02,00,00,01,05,00,00,00
,00,00,05,15,00,00,00,a0,5f,84,1f,\\\n', '
5e,2e,6b,49,ce,12,03,03,f4,01,00,00,
01,05,00,00,00,00,00,05,15,00,00,00,a0,\\\n', '
5f,84,1f,5e,2e,6b,49,ce,12,03,0
3,f4,01,00,00\n', '\n']
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole]
"EnableDCOM"="Y"
"DefaultLaunchPermission"=hex:01,00,04,80,64,00,00,00,80,00,00,00,00,00,00,00,

14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,\

00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,00,\

00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,02,00,00,00,00,00,\

05,20,00,00,00,20,02,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,5f,84,1f,\

5e,2e,6b,49,ce,12,03,03,f4,01,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,\
5f,84,1f,5e,2e,6b,49,ce,12,03,03,f4,01,00,00
 
W

wittempj

It works fine for me on NT. I think it has nothing to do with Python
but with the way the file is created - what windows version are you on?
Also note the possibility the '/' - I prefer a noatation like below to
avoid ambiguity.

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
py> f = open(r"d:\test.reg")
py> r = f.read()
py> print r
REGEDIT4

I would do it like this however, then join all lists from various .reg
files:
py> f = open(r'd:\test.reg')
py> r = f.readlines()
py> print r
['REGEDIT4\n', '\n',
'[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Ole]\n', '"Enabl
eDCOM"="Y"\n',
'"DefaultLaunchPermission"=hex:01,00,04,80,64,00,00,00,80,00,00,0
0,00,00,00,00,\\\n', '
14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00
,00,01,01,00,00,00,\\\n', '
00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,
00,00,01,01,00,00,00,00,\\\n', '
00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,0
0,00,00,01,02,00,00,00,00,00,\\\n', '
05,20,00,00,00,20,02,00,00,01,05,00,00,00
,00,00,05,15,00,00,00,a0,5f,84,1f,\\\n', '
5e,2e,6b,49,ce,12,03,03,f4,01,00,00,
01,05,00,00,00,00,00,05,15,00,00,00,a0,\\\n', '
5f,84,1f,5e,2e,6b,49,ce,12,03,0
3,f4,01,00,00\n', '\n']
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole]
"EnableDCOM"="Y"
"DefaultLaunchPermission"=hex:01,00,04,80,64,00,00,00,80,00,00,00,00,00,00,00,

14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,\

00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,00,\

00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,02,00,00,00,00,00,\

05,20,00,00,00,20,02,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,5f,84,1f,\

5e,2e,6b,49,ce,12,03,03,f4,01,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,\
5f,84,1f,5e,2e,6b,49,ce,12,03,03,f4,01,00,00
 
T

Thorsten Kampe

* (e-mail address removed) (2005-06-22 13:59 +0100)
It works fine for me on NT. I think it has nothing to do with Python
but with the way the file is created - what windows version are you on?

Windows uses UTF-16 since Windows 2000. Regedit offers the possibility
to export in the old Win9x/NT4 format.
 

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
474,259
Messages
2,571,295
Members
47,931
Latest member
alibsskamoSeAve

Latest Threads

Top