Greetings fellow monks,

I'm not sure if my problem is with my misunderstanding of how the registry works, or my somehow failing to use the Win32::TieRegistry module correctly.  My intent is to delete the key 'HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1' from the Windows XP registry on my laptop computer.

First of all, here's my code:

#!/usr/bin/perl -w # # Attempt to delete 'HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1' from the # Windows Registry, using Win32::TieRegistry. ## ############# # Libraries # ############# use strict; use warnings; use Data::Dumper; use Win32::TieRegistry( Delimiter => '/' ); ################ # Main Program # ################ # Step 1 -- assign variables my $label = "xyzzy_1"; my $key = 'HKEY_CLASSES_ROOT/Folder/shell'; my $h_shell = $Registry->{$key}; (defined $h_shell) or die "Unable to find registry key '$key'\n"; # Step 2 -- Display all keys for HKEY_CLASSES_ROOT/Folder/shell print "[Values for '$key']\n"; my $idx = 0; foreach my $key (keys %$h_shell) { printf " %3d. %s\n", ++$idx, $key; } print "\n\n"; # Step 3 -- Validate that the label 'xyzzy_1' was found if (!exists($h_shell->{$label})) { die "No such label for '$key' => '$label'\n"; } # Step 4 -- Delete 'xyzzy_1' from 'HKEY_CLASSES_ROOT/Folder/shell' print "Deleting label '$label' ...\n"; my $result = delete($h_shell->{$label}); print "Result of delete: '$result'\n";

Prior to running the program, I created a registry key "HKEY_CLASSES_ROOT/Folder/shell/xyzzy_1", which along with the existing keys for the parent key look like this according to regedit (note my use of '###' for the folder icon):

[+]-### FName.Factoid [+]-### FName.Factoid.2 [+]-### fndfile {+]-### Folder | |--### DefaultIcon | [-]-### shell | | [+]--### explore | | [+]--### open | | |---### xyzzy_1 | [+]-### shellex [+]-### fonfile [+]-### FormHost.FormHost

When I run the program, the output I get is:

D:\Tools\rmfolder>regtest.pl [Values for 'HKEY_CLASSES_ROOT/Folder/shell'] 1. explore/ 2. open/ 3. xyzzy_1/ Deleting label 'xyzzy_1' ... Result of delete: 'The system cannot find the file specified. '

Can anyone suggest why the delete isn't apparently working (both from the error message, and the fact that it still shows up in the registry)?  Am I missing some other step or steps?  I'm using Win32::TieRegistry version 0.20 (which comes with my ActiveState Perl version 5.10.0); should I be updating to a later version of Win32::TieRegistry?

Thanks in advance for any help!


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Unable to delete registry keys using Win32::TieRegistry by liverpole

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.