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

I am looking to use a batch Perl script to save my Outlook Express Mail Rules. I am able to use Win32::TieRegistry to save the registry key to a hive file. But the intent is to use it to restore my setting if I ever had a drive crash and the hive file is not good enough. The problem is that the registry path includes a unique GUID which would change if I reinstalled winxp. So I need the information in a registry script file, so I can edit the GUID and merge the rules into the new registry.

How can I do this?

thanks,
Kevin

Replies are listed 'Best First'.
Re: win32::TieRegistry script (serialize)
by tye (Sage) on Jun 11, 2004 at 02:20 UTC

    Use any of the serialization modules, preferably one that outputs text. For example, I've done this with Data::Dumper (for non-huge registry keys). It recording the bless state was a pain but easy enough to remove. Then just assign the reconstituted hash in order to reconstruct the whole Registry tree.

    Update: You can also use TieRegistry to load and modify the information in the hive before you restore it (or use regedt32 to do this).

    - tye        

      All you really need is the (somewhat undocumented) /e flag on REGEDIT and it will dump the hive for you in native *.REG format ready for reimport.

      C:\>regedit /e active.reg HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState C:\>type active.reg Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState] [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\ActivePerl] "CurrentVersion"="635" [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\ActivePerl\635] @="D:\\Perl\\" [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\ActivePerl\635\Help] @="D:\\Perl\\html\\index.html" [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript] [HKEY_LOCAL_MACHINE\SOFTWARE\ActiveState\PerlScript\1.0] "NoCaseCompare"=dword:00000001 "EnabledZones"=dword:00000010 "EnableEventLogMsgs"=dword:00000000 C:\>

      cheers

      tachyon

        thanks tachyon! that worked nicely.