#!/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";
####
[+]-### FName.Factoid
[+]-### FName.Factoid.2
[+]-### fndfile
{+]-### Folder
| |--### DefaultIcon
| [-]-### shell
| | [+]--### explore
| | [+]--### open
| | |---### xyzzy_1
| [+]-### shellex
[+]-### fonfile
[+]-### FormHost.FormHost
##
##
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.
'