crazina has asked for the wisdom of the Perl Monks concerning the following question:

I want to Export the registry information (Windows, regedit) to a file. I want to do it in perl. Normally, a user would type "regedit" in the Run box. Go to "File" menu and select "Export". This would export a file. I want to write a program that would automatically run the regedit and export the file. Does anyone know how to do it? What module to call?
  • Comment on Output Registry (Windows) by Exporting file

Replies are listed 'Best First'.
Re: Output Registry (Windows) by Exporting file
by muntfish (Chaplain) on Jun 24, 2005 at 09:38 UTC

    Although some Win32 suggestions have been made, if you really do just want to export to a file, a non-perl solution may be easier, from an installation perspective.

    The regedit program does have command-line options for this sort of thing, although they are not particularly well-documented in Windows Help. To dump the whole registry to a file, you can use the /e switch followed by a filename, e.g:

    regedit /e regdump.txt

    Or you can just get a section, by giving the key after the filename:

    regedit /e reg.txt "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT"

    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
Re: Output Registry (Windows) by Exporting file
by marto (Cardinal) on Jun 24, 2005 at 09:09 UTC
Re: Output Registry (Windows) by Exporting file
by ZlR (Chaplain) on Jun 24, 2005 at 13:19 UTC
    I agree with muntfish .

    Depending on what you want to do with this reg file, it may be easier to use a system call to regedit.exe . Win32::TieRegistry was usefull to me to modify or read the registry 'in place' , that is on the running system .

    That said I never tried Win32::TieRegistry::Dump .

    The file produced by a regedit.exe export will be in the UTF-16-LE format (first two bytes : FF FE) which may cause you problem if you want to programatically modify it, before reloading it for example .

Re: Output Registry (Windows) by Exporting file
by Jenda (Abbot) on Jun 24, 2005 at 14:42 UTC

    If (increasingly unlikely) you are used to Win32::Registry you may try this patch that adds the Export/Import/Load/Unload/FindKey/FindValue/... functionality to the module. If we live long enough to see a new version of libwin32 released it may even become the official version.

    Jenda
    XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.