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

Hi there

I try to automate some stuff on Windows. One of this items is dumping the Windows registry to a file. When being admin (in cli and running Perl code) the output differs over 100Mbyte. The output on CLI is bigger.

On command line

regedit /e /y e:\temp\regdump.reg # result file(332Mb)

In Perl

$DumpFile = "e:\\temp\\registry.reg"; system("regedit", "/e", "/y", $DumpFile); #(resultfile 208Mb)

What am I doing wrong?/Bug in Perl/Something else?

I'm running on Windows 8

Replies are listed 'Best First'.
Re: registry dump to file output differs from DOS cli and system ?
by Discipulus (Canon) on Mar 05, 2015 at 08:38 UTC
    not seems Perl related: a hint from my experience: when you doubt about a Perl bug you wrong or became a master..
    Anyway /y is not a recognized switch, see regedit, the correct sysntax seems to be:
    REGEDIT /E pathname regedit /E y:\reg_cmd2.reg "/"
    I tryed and the first time i had the registry dumped, then i deleted the file and i was no more able to dump a second time... seems a very bad feature coming from the ancient past: now only usable to launch the GUI

    Try instead reg as in reg  EXPORT HKU c:\file.reg
    HtH
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Hi L*

      Thanks for your reply. I based this /y option on info found on this webpage: https://technet.microsoft.com/en-us/library/cc742017.aspx

      Unfortunately removing /y option gave the same result.

      The reg command seems interesting. Unfortunately, it seems you can only export one key at the time, the sum of all 5 keys was 80Mb more that a regular registry dump

      further on it seems that regedit /e only dumps two keys: HKEY_LOCAL_MACHINE and HKEY_USERS, not the other base keys. This is as CLI and in Perl. Will try to run a diff to see what is missing in Perl -> system......

      Is it possible to see what call Perl sends to Windows to figure out why there are two different results....

        The link you provided is for REG command not REGEDIT
        y>reg export HKLM cmd.reg Operation completed succesfully. lt@MC-TAVIANI:y>perl -e "system qq(reg export HKLM perl.reg)" Operation completed succesfully. y>dir *.reg Directory y:\ 06/03/2015 08:54 191.906.582 cmd.reg 06/03/2015 08:54 191.906.582 perl.reg
        Anyway you can simply do something to dump all root keys:
        my @rootk = qw(HKLM HKCU HKU HKCR); foreach my $root ( @rootk ) { my $ile = $root.'.reg'; system qq(reg export $root $file); }
        That said untill now there is nothing about Perl in this thread.. So if we want something perlish as solution you can try Win32::TieRegistry: is stable, updated, and i use it since 10+ years to remotely create ODBC on winz systems. Looping all the keys with Win32::TieRegistry (or the name is Win32::TyeRegistry ? ;=) ) and write a Config::INI file, double quoting all strings, seems a feasible way

        HtH
        L*
        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: registry dump to file output differs from DOS cli and system ?
by GotToBTru (Prior) on Mar 05, 2015 at 19:54 UTC

    Are the files in fact different, beyond the file size?

    Dum Spiro Spero