Win32::OLE "Member not found"

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Am attempting to run the simple script as follows (sourced from: )

use strict;
use warnings;
use Data::Dumper;
use Win32::OLE;
$Win32::OLE::Warn = 3;

#use lib 'H:\dev\perl\NSLC-Store-Mgmt\lib';
#use NSLC::Store::Mgmt;

my %args;

$args = 'TESTVAR';
$args = 'TESTVALUE';
$args = '.';


sub set_env_var {
    my ($args,) = @_;
    my $strVarName  = $args->;
    my $strVarValue = $args->;
    my $strComputer = $args->;

    my $objVarClass = Win32::OLE->GetObject('winmgmts://' .
$strComputer . '/root/cimv2:Win32_Environment');
    my $objVar = $objVarClass->SpawnInstanceobjVar->Name eq
    $objVar-> = $strVarValue;
    $objVar-> = '<SYSTEM>';
    $objVar->PutWScript->Echo('Created environment variable ' .

The following message is returned.
retrying default method at C:/Perl/site/lib/Win32/OLE/ line
Win32::OLE(0.1403) error 0x80020003: "Member not found"
    in METHOD/PROPERTYGET "" at H:\dev\perl\test\  line 28
shell returned 9

I am completely new to using perl in a windows environment and am not
sure where to start debugging.  I have read all that I can via module
docs and web information but am still having no luck.
As far as I can tell, syntactically the script is fine but I am not
sure how the guts of $objVarClass->SpawnInstanceobjVar->Name eq
$strVarName; is working.  I am running this on XP pro using activeperl

Any insight would be appreciated.


Re: Win32::OLE "Member not found" wrote:
Quoted text here. Click to load it

This code is buggy and I suspect nobody ever tested it.

Quoted text here. Click to load it

These have to be 2 statements:

my $objVar = $objVarClass->SpawnInstance_  # note the underscore
$objVar-> = $strVarName;

Quoted text here. Click to load it

and again:

WScript->Echo('Created environment variable ' . $strVarName);
# at least I think so, I don't know WScript

Quoted text here. Click to load it

For using the WMI interface the M$ WMI Reference is the best information


'%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....

Re: Win32::OLE "Member not found"

Quoted text here. Click to load it

Oh man....did I really miss that?  Thanks, I have it somewhat working
now :).

Site Timeline