Re: Reading registry export files
* [EMAIL PROTECTED] (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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading registry export files
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading registry export files
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 -- http://mail.python.org/mailman/listinfo/python-list
RE: Reading registry export files
[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: | | >>> f=open('c:/documents and settings/myname/desktop/test.reg','r') | >>> r=f.read() | >>> print r It's encoded with utf-16. You need to do something like this: import codecs f = codecs.open ("c:/temp/temp.reg", encoding="utf_16") # .reg files seems to have an initial BOM so need need to specify endianness text = f.read () f.close () print text TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list