[EMAIL PROTECTED] wrote:
> I would like to thank everyone for their input on this issue. I
> appologize for my late response as I have been trying to
> implement most of the suggestions that were sent out on this.
>
> Jan's code sample below produced the same result on the x64bit machine
> as it is still being directed to the 32bit registry section
> ---
> use Win32::OLE;
> my $shell = Win32::OLE->new("WScript.Shell");
> print $shell->RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows
> NT\\CurrentVersion\\HotFix\\');
> ----
>
> I am currently trying to use WMI to make the registry calls however my
> code (shown below) does not seem to work.
> The VBScript equivalent however does work ( I used Activestates PDK
> VBscript converter to generate the perl code)
> Can any one help me with this WMI perl code I just have it pulling a
> String from the registry as shown.
>
> #==========Perl Code====================
> #!perl
> use Win32::OLE;
> use Warnings;
> use constant HKEY_CURRENT_USER => 0x80000001;
> use constant HKEY_LOCAL_MACHINE => 0x80000002;
> $strComputer = '.';
>
> $oReg =
> Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}!\\\\' .
> $strComputer . '\\root\\default:StdRegProv');
>
> $strKeyPath = "SOFTWARE\\Microsoft\\Windows
> NT\\CurrentVersion\\HotFix\\KB896424";
> $strValueName = "Comments";
> $oReg->GetStringValue(HKEY_LOCAL_MACHINE,$strKeyPath,$strValueName,$strValue);
>
> print 'The Comment is : ' . $strValue, "\n";
> #============
>
> ' =========VBSCRIPT CODE===================
> const HKEY_CURRENT_USER = &H80000001
> const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB896424"
> strValueName = "Comments"
> oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
> wscript.echo "The Comment is : " & strValue
> '============================================
This seems to work on 32:
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
use constant HKEY_CURRENT_USER => 0x80000001;
use constant HKEY_LOCAL_MACHINE => 0x80000002;
my $strComputer = Win32::NodeName || '.';
my $oReg = Win32::OLE->GetObject(
'winmgmts:{impersonationLevel=impersonate}!\\\\' . $strComputer .
'\\root\\default:StdRegProv') or die "GetObject: " . Win32::OLE->LastError();
my $path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HotFix\\KB896424";
my @names = ('', 'Backup Dir', 'Comments', 'Fix Description', 'Installed',
'Installed By', 'Installed On', 'Service Pack', 'Valid');
my @types = (VT_BSTR, VT_BSTR, VT_BSTR, VT_BSTR, VT_I4, VT_BSTR, VT_BSTR,
VT_I4, VT_I4);
my $strKeyPath = $path;
for (my $ii = 0; $ii < @names; ++$ii) {
my $strValueName = $names[$ii];
if ($types[$ii] == VT_BSTR) {
my $strValue = Variant (VT_BSTR|VT_BYREF, '<Not Set>');
my $ret = $oReg->GetStringValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $strValue);
$strValueName = '(Default)' if not $strValueName;
print "$strValueName: '", $strValue->Value(), "'\n";
} else {
my $Value = Variant (VT_I4|VT_BYREF, 0);
my $ret = $oReg->GetDWORDValue(HKEY_LOCAL_MACHINE,
$strKeyPath, $strValueName, $Value);
print "$strValueName: '", $Value->Value(), "'\n";
}
}
__END__
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs