That's because the default is to attempt to access it with Read/Write
permissions, which will give you an Access Denied error if you don't
have both read and write.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Richard Burns-Allan
Sent: Thursday, June 08, 2006 5:19 AM
To: perl-win32-admin@listserv.ActiveState.com
Subject: RE: Tieregistry problems with Add/Remove Programs list

Thanks for your help everyone - I think I've uncovered the problem.
It seems to be permissions on the registry keys. Due to our security
policies here, my user account is not an administrator on my machine -
and indeed no ordinary user accounts here are.
What seem strange is that it is still able to read the key name, but not
the values within all the keys. Most of the keys with GUID names are
created by Windows Installer, so have the default permissions - read
only everyone, full access adminnistrators. The other keys don't, they
seem to have all sorts. By using the following I get everything on the
list:

 #!/usr/bin/perl -w
use strict;
use warnings;
use Win32::TieRegistry qw(:KEY_);
use Win32::TieRegistry (Delimiter=>"/") ;

my $key =
'LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstall/';

my $softwareKey = new Win32::TieRegistry($key,{Access=>KEY_READ(),
Delimiter=>"/"})
    or  die "Can't connect to software key: $^E\n";
my %regKey;

$softwareKey->Tie(\%regKey);
my $count=0;

foreach my $item ( values(%regKey) ) {
    # beware: $subkey comes with a trailing slash
    #my $item = $regKey{$subkey};
    my $name = $item->{DisplayName} || next;
    print "$name   \n";
    $count++;
}
print $count;

On my machine this gives a count of 112 items. But, if I remove the
Access=>KEY_READ(), I get only 78 and the symptoms as before - the key
name is printed, but not the DisplayName value.

--Richard Burns-Allan


-----Original Message-----
From: Timothy Johnson [mailto:[EMAIL PROTECTED] 
Sent: 07 June 2006 16:56
To: Richard Burns-Allan; perl-win32-admin@listserv.ActiveState.com
Subject: RE: Tieregistry problems with Add/Remove Programs list


I'm not seeing the problem you're describing.  Here's the code I used
(one small change to make sure we're getting the "GUID keys".

####################
#!/usr/bin/perl -w
use strict;
use warnings;

use Win32::TieRegistry(Delimiter => '/');

my $key =
'LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstall';

foreach my $subkey ( keys(%{$Registry->{$key}}) ) {
    # beware: $subkey comes with a trailing slash
    my $name = $Registry->{"$key/$subkey/DisplayName"};
    print "$subkey => $name\n";
}

#####################

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Richard Burns-Allan
Sent: Wednesday, June 07, 2006 8:03 AM
To: perl-win32-admin@listserv.ActiveState.com
Subject: Tieregistry problems with Add/Remove Programs list

Sorry if this has been asked before - I've looked and couldn't find it.
I'm fairly new to this and having some problems getting Tieregistry to
do what I want it to.
I'm using the following (pinched from elsewhere on the net) to get the
display names of items in the Add/Remove Programs list which is
HKLM/Software/Microsoft/Windows/CurrentVersion/Uninstall/
It works to a certain extent - but misses out all the subkeys which have
the software GUID instead of a string as the subkey name.
For example on my machine the subkey
{04AE4390-AC57-44A1-9165-FAF5C6BFB14E} does have a value name of
DisplayName, which has the value Autodesk Deployment Wizard, but this
doesn't print out on the list.
I've tried quoting the subkey, escaping the curlys, removing them  -
allsorts really, but can't get it to work. Please help.

#!/usr/bin/perl -w
use strict;
use warnings;

use Win32::TieRegistry(Delimiter => '/');

my $key =
'LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstall';

foreach my $subkey ( keys(%{$Registry->{$key}}) ) { # beware: $subkey
comes with a trailing slash my $name =
$Registry->{"$key/$subkey/DisplayName"} || next; print "$name\n"; }

Thanks,
--Richard Burns-Allan

DipComp DipIT BSc(Hons) MBCS
MCSA(2000 & 2003) MCSE(NT4, 2000, 2003) Security+

IT Systems Engineer
Ross-shire Engineering Limited
Tel: 01463 870049


_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to