Parse Win32 Registry With Perl

Parse::Win32Registry is a module for parsing Windows Registry files, allowing you to read the keys and values of a registry file without going through the Windows API. It provides an object-oriented interface to the keys and values in a registry file. Registry files are structured as trees of keys, with each key containing further subkeys or values. The module is intended to be cross-platform, and run on those platforms where Perl will run.

It supports both Windows NT registry files (Windows NT, 2000, XP, 2003) and Windows 95 registry files (Windows 95, 98, and Millennium Edition).

Start by creating a Registry object from a valid registry file. Use the Registry object's get_root_key method to obtain the root key of that registry file. This root key is your first Key object. From this key, you can explore the Key and Value objects that comprise the registry file using the methods described below. Data is read directly from a registry file when a Key or Value object is created, and discarded when the Key or Value object is destroyed. This avoids any delay in parsing an entire registry file before any Key or Value object is instantiated as it is anticipated that generally code will only be extracting a subset of the keys and values contained in a registry file.


protection problem reading registry -- Win 2K

I tried an elementary read of my SYSTEM file on Win2k and it failed
for protection failure...Can anyone explain why this is? I examined regsvc.exe which I thought was to blame, but even after I halted it, I got the protection error. Here's the code and error message.

my registry_file=$ENV{SystemRoot} . "\\System32\\Config\\SOFTWARE";
my $registry = Parse::Win32Registry->new( $registry_file ) ;
my $root_key =$registry ->get_root_key('HKEY_LOCAL_MACHINE');
my $root_key_name = $root_key -> get_name;
my $root_key_path = $root_key -> get_path;
my $key_to_pl = $root_key->get_subkey 'SOFTWARE\\Classes\\.pl');
if (! defined $key_to_pl || !$key_to_pl)
{
print stderr "Unable to locate .pl key in Classes in registry...please repair your file assocition before proceeding\n";
exit 8;
}
my $key_to_Perl = $root_key ->
get_subkey 'SOFTWARE\\Classes\\.pl\\Perl');
if (! defined $key_to_Perl || !$key_to_Perl)
{
print stderr "Unable to locate Perl key beneath .pl key in registry...please repair your perl
file association before proceeding\n";
exit 9;
}
my $key_to_ShellNew = $key_to_Perl -> get_subkey('ShellNew');
if (! defined $key_to_ShellNew || !$key_to_ShellNew)
{
print stderr "Unable to locate ShellNew key beneath Perl key in registry...please repair your
perl file association before proceeding\n";
exit 10;
}
print stder "File association for Perl is ok\n";

The error message:
Unable to open 'C:\WINNT\System32\Config\SOFTWARE': Permission denied at C:\vals-09-15-09\ipv.pl
line 172 -- That's the line of the parse

None of the HRS bits are set on the file

Thanks In advance...

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <quote> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
.