PERL

Win32

Registry manipulation

use Win32::Registry;
qx(regedit /s "c:\\Program Files\\Microsoft Office\\Office\\power.reg);
$main::HKEY_CURRENT_USER->Open("Software\\Microsoft", $Microsoft) || die "Can't open Software\\Microsoft key: $!\n";
$Eight = MakeTree($Microsoft, "Office\\8.0");
$Eight->GetKeys(\@Eight);
foreach $key (@Eight) {    
	$Key->SetValue("Default", REG_SZ, $HomeDir);
	$Key->GetValues(\%KeyVals);
	if (%KeyVals) {
	     $KeyVal = $KeyVals{""};
             $AutoGrammer = $KeyVals{"AutoGrammar"};
	} else {
		$Key->SetValueEx("AutoGrammar", 0, REG_SZ, "0");
		$Key->SetValueEx("Run Already", 0, REG_DWORD, "1");
		}
		

     # Create multilevel hive structure
     sub MakeTree {
         my ($SubTree, $Path) = @_;
         $Path =~ s#^\\##;
         my (@KeyList) = split(/\\/, $Path);
         my $key;
         my $RegKey = $SubTree;
         foreach $key (@KeyList) {
     #        print "Key being created is: $key\n";
             $RegKey->Create($key, $RegKey)
                || die "Can't create $key key: $!\n";
         }
         return $RegKey;
     }