bluegroper
Technical User
Hi perl folks
I've been challenged by a small Windoze registry problem.
Specifically, I need to delete an entire branch, ie a single key together with all the values and subkeys of that single key, and values of those subkeys. No exceptions, and no questions asked.
I've looked at all the modules I can find, including Win32::TieRegistry, but they all refuse to delete branches with existing subkeys.
So I made the following code. You can tell that I'm new to perl. I'm glad to say that it works, BUT, can somebuddy show me a better way to write this stuff. All those hex codes are tedious, and make the perl code impossible to read.
Thx for the clues.
And I'm still wondering why the "
" tags don't work as intended.
I've been challenged by a small Windoze registry problem.
Specifically, I need to delete an entire branch, ie a single key together with all the values and subkeys of that single key, and values of those subkeys. No exceptions, and no questions asked.
I've looked at all the modules I can find, including Win32::TieRegistry, but they all refuse to delete branches with existing subkeys.
So I made the following code. You can tell that I'm new to perl. I'm glad to say that it works, BUT, can somebuddy show me a better way to write this stuff. All those hex codes are tedious, and make the perl code impossible to read.
Thx for the clues.
Code:
#! /perl -w
# RegFix.pl for Win32
# SYNOPSIS
# Deletes some pesky registry entries with sub-keys
# COMPILER DIRECTIVES
#
use strict; use diagnostics;
use English;
use Win32;
# VARIABLES
#
my $Debug = 0; # 1 is debug mode, no update of registry
my $TempRegFile = "$ENV{TEMP}\\TempReg.reg";
my $RegString;
# SANITY CHECKS
#
open (REGFILE, ">$TempRegFile") or die "Cannot open $TempRegFile : $! \n";
# MAIN
#
# Create a .reg file
$RegString = "\xFF\xFE\x57\x00\x69\x00\x6E\x00\x64\x00\x6F\x00\x77\x00\x73\x00";
$RegString = "$RegString"."\x20\x00\x52\x00\x65\x00\x67\x00\x69\x00\x73\x00\x74\x00\x72\x00";
$RegString = "$RegString"."\x79\x00\x20\x00\x45\x00\x64\x00\x69\x00\x74\x00\x6F\x00\x72\x00";
$RegString = "$RegString"."\x20\x00\x56\x00\x65\x00\x72\x00\x73\x00\x69\x00\x6F\x00\x6E\x00";
$RegString = "$RegString"."\x20\x00\x35\x00\x2E\x00\x30\x00\x30\x00\x0D\x00\x0A\x00\x0D\x00";
$RegString = "$RegString"."\x0A\x00\x5B\x00\x2D\x00\x48\x00\x4B\x00\x45\x00\x59\x00\x5F\x00";
$RegString = "$RegString"."\x43\x00\x55\x00\x52\x00\x52\x00\x45\x00\x4E\x00\x54\x00\x5F\x00";
$RegString = "$RegString"."\x55\x00\x53\x00\x45\x00\x52\x00\x5C\x00\x53\x00\x6F\x00\x66\x00";
$RegString = "$RegString"."\x74\x00\x77\x00\x61\x00\x72\x00\x65\x00\x5C\x00\x53\x00\x6F\x00";
$RegString = "$RegString"."\x66\x00\x74\x00\x77\x00\x61\x00\x72\x00\x65\x00\x5F\x00\x74\x00";
$RegString = "$RegString"."\x6F\x00\x5F\x00\x64\x00\x65\x00\x6C\x00\x65\x00\x74\x00\x65\x00";
$RegString = "$RegString"."\x5D\x00\x0D\x00\x0A\x00\x0D\x00\x0A";
print REGFILE "$RegString";
close REGFILE;
# Now fix the registry
system "Regedit.exe \/s $TempRegFile > nul: \n" if ($Debug == 0);
exit 0;
And I'm still wondering why the "
Code: