I'm trying to accomplish the utterly trivial task of extracting and displaying data from the registry, using the StdRegProv class with WMI. Using VBScript, it's simple enough. The following script prints the registered owner (I used a script in "WMI: Windows Management Instrumentation" for inspiration):
---8<---cut here---8<--- Option Explicit Dim refRegistry Dim strSKPath Dim strValueName Dim strValueData Const HKEY_LOCAL_MACHINE = &H80000002 Set refRegistry = GetObject("winmgmts://rdesousa2/root/default:StdRegProv") strSKPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion" strValueName = "RegisteredOwner" If refRegistry.GetStringValue( _ HKEY_LOCAL_MACHINE, strSKPath, strValueName, strValueData) = 0 Then WScript.Echo "RegisteredOwner: " & strValueData Else WScript.Echo "Failed" End If ---8<---cut here---8<--- My attempted translation, in perl: ---8<---cut here---8<--- use strict; use Win32::OLE qw(in with); my ($wmi, $services, $set); my $value; my $HKEY_LOCAL_MACHINE = 0x80000002; $wmi = Win32::OLE->GetObject ("winMgmts://rdesousa2/root/default:StdRegProv") or die "Cannot access WMI on local machine: ", Win32::OLE->LastError; $wmi->GetStringValue($HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "RegisteredOwner", $value) or die "Cannot access WMI on remote machine: ", Win32::OLE->LastError; print "Value: $value\n"; undef $services; undef $wmi; ---8<---cut here---8<--- When I execute my perl script, I get the following error: Cannot access WMI on remote machine: 0 at D:\src\WMI\registry.pl line 14. I'm sure it's something simple, such as my lack of understanding Win32::OLE (I was a UNIX-only programmer until last Friday ;) . Pointers would be most appreciated. Regards, Greg P.S. I know this type of thing can be done with other perl modules, but I would like to solve it with WMI. _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs