Hi Everyone!
I'm trying to write a perl script that will load and unload NTUSER.DAT on remote NT servers.  From examples I've found, I hacked together a test script, listed below, that works except for the unload. When I run the script, I get the following output:
 
> Connected OK
> Key Loaded OK
> Value = |smsrun32.exe|
> Error: The handle is invalid
 
The weird part is, when I check the remote registry, using REGEDT32, the key does get unloaded.
I'm using Perl 5.6, build 623.  Also, I am running this under the Administrator account.
 
Does anyone have any ideas on what I'm doing wrong? Any suggestions would be greatly appreciated!
 
Thanks again!
Mark Halley
 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
use Win32::TieRegistry (Delimiter=>"/",AllowLoad => 1,AllowSave => 1,qw(KEY_READ KEY_WRITE KEY_ALL_ACCESS));
my $Machine = "TESTSRV";
my $RRoot;
my $RKey;
my $Value;
my $KeyName = "Mark";
 
if ($RRoot = $Registry->Connect("$Machine","HKEY_USERS",{Access=>KEY_ALL_ACCESS}))
{
    print "Connected OK\n";
} else {
    die "Unable to connect to $Machine\n";
}
 
if ($RKey = $RRoot->Load("c:\\winnt\\profiles\\username\\ntuser.dat",$KeyName,{Access=>KEY_ALL_ACCESS}))
{
    print "Key loaded ok\n";
} else {
    die "Unable to load key\n";
}
 
if ($Value = $RKey->{"Software/Microsoft/Windows NT/CurrentVersion/Windows//Load"})
{
    print "Value = |$Value|\n";
} else {
    print "Unable to get info\n";
}
 
# $RKey->UnLoad || print "Unable to unload key from registry\n";
 
if (Win32API::Registry::RegUnLoadKey($RRoot, $KeyName))
{
    print "Unloaded ok\n";
} else {
    print "Error: " . Win32API::Registry::regLastError() . "\n";
}
 

Reply via email to