Dear monks, I'm looking for a way to export windows registry. I know about Win32::TieRegistry module which works fine but this not what I want. I want to export a key with all subkeys using the same format the as native regedit.exe tool. This format is a bit specific, something like text but "enhanced" registry types like REG_MULTI_SZ are exported as hex string:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\wwe] "binary"=hex:00,11 "dword"=dword:00000010 "multi-sz"=hex(7):66,00,69,00,72,00,73,00,74,00,20,00,6c,00,69,00,6e,0 +0,65,00,\ 00,00,73,00,65,00,63,00,6f,00,6e,00,64,00,20,00,6c,00,69,00,6e,00,65 +,00,00,\ 00,74,00,68,00,69,00,72,00,64,00,20,00,6c,00,69,00,6e,00,65,00,00,00 +,00,00 "reg-sz"="string" "expand-sz"=hex(2):25,00,70,00,61,00,74,00,68,00,25,00,00,00
It's easy to get following output using Win32::tieRegistry:
"binary"=3:<one or two non-ASCII character displayed here> "dword"=4:0x00000010 "multi-sz"=7:first<null delimiter here>line-second line<null delimiter + here>third line<null delimiter here><null delimiter here> "reg-sz"=1:string "expand-sz"=2:%path%
if I use this code:
use Modern::Perl; use Win32::TieRegistry ( Delimiter=>'/', SplitMultis=>0, FixSzNulls => +1, ArrayValues => 0, qw( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY REG_MULTI_SZ KEY_READ KEY_WRITE KEY_ALL_ACCESS ), ); my $reg_obj = $Registry->Open("LMachine/Software/wwe", { Access=>'KEY_ +READ' } ) or die "Error: $^E\n"; foreach my $value ($reg_obj->ValueNames()) { my ($valuedata, $valuetype) = $reg_obj->GetValue( $value ); my %valuetypes = ( ); say qq{"$value"=$valuetype:$valuedata}; }

I'm looking for a long time for a module or a ready script wich exports the registry in the same format but I didn't found anything until now.

Is there a way to get the "regedit" output without doing manual pack/unpack? I don't want to do it as I'm not really familiar with pack. I know about the possibility to call regedit.exe with an /E parameter (or reg.exe) but this not enough I want to process remote machines too. It would be OK if the solution is limited to Windows plattform, I don't think there is some crasy user who want to start it somewhere else :-) I'm also open to any other ideas. Thank you in advance.

In reply to Win32 registry export by wwe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.