Click here to get back home

Win32::OLE "Member not found"

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Win32::OLE "Member not found" Adam.L.MacKinnon 04-03-2008
Posted by Adam.L.MacKinnon on April 3, 2008, 12:09 pm
Please log in for more thread options
Hi,

Am attempting to run the simple script as follows (sourced from:
http://techtasks.com/code/viewbookcode/443)

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 = '.';

set_env_var(\%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
$strVarName;
$objVar-> = $strVarValue;
$objVar-> = '<SYSTEM>';
$objVar->PutWScript->Echo('Created environment variable ' .
$strVarName);
}

The following message is returned.
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line
156.
Win32::OLE(0.1403) error 0x80020003: "Member not found"
in METHOD/PROPERTYGET "" at H:\dev\perl\test\setenv.pl 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
5.8.8(820).

Any insight would be appreciated.

Thanks

Posted by Thomas Kratz on April 8, 2008, 5:09 am
Please log in for more thread options
Adam.L.MacKinnon@gmail.com wrote:
> Hi,
>
> Am attempting to run the simple script as follows (sourced from:
> http://techtasks.com/code/viewbookcode/443)

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

> 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 = '.';
>
> set_env_var(\%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
> $strVarName;

These have to be 2 statements:

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

> $objVar-> = $strVarValue;
> $objVar-> = '<SYSTEM>';
> $objVar->PutWScript->Echo('Created environment variable ' .
> $strVarName);

and again:

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


> }
>
> The following message is returned.
> retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line
> 156.
> Win32::OLE(0.1403) error 0x80020003: "Member not found"
> in METHOD/PROPERTYGET "" at H:\dev\perl\test\setenv.pl 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
> 5.8.8(820).

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

http://msdn2.microsoft.com/en-us/library/aa394572%28VS.85%29.aspx

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*3),,mg,@_=mapsplit;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-

Posted by Adam.L.MacKinnon on April 8, 2008, 3:20 pm
Please log in for more thread options
> Adam.L.MacKin...@gmail.com wrote:
> > Hi,
>
> > Am attempting to run the simple script as follows (sourced from:
> >http://techtasks.com/code/viewbookcode/443)
>
> This code is buggy and I suspect nobody ever tested it.
>
>
>
> > use strict;
> > use warnings;
> > use Data::Dumper;
> > useWin32::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 = '.';
>
> > set_env_var(\%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
> > $strVarName;
>
> These have to be 2 statements:
>
> my $objVar = $objVarClass->SpawnInstance_ # note the underscore
> $objVar-> = $strVarName;
>
> > $objVar-> = $strVarValue;
> > $objVar-> = '<SYSTEM>';
> > $objVar->PutWScript->Echo('Created environment variable ' .
> > $strVarName);
>
> and again:
>
> $objVar->Put_;
> WScript->Echo('Created environment variable ' . $strVarName);
> # at least I think so, I don't know WScript
>
>
>
> > }
>
> > The following message is returned.
> > retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line
> > 156.
> >Win32::OLE(0.1403) error 0x80020003: "Member not found"
> > in METHOD/PROPERTYGET "" at H:\dev\perl\test\setenv.pl 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
> > 5.8.8(820).
>
> For using the WMI interface the M$ WMI Reference is the best information
>
> http://msdn2.microsoft.com/en-us/library/aa394572%28VS.85%29.aspx
>
> Thomas
>
> --
> $/=$,,$_=<DATA>,s,(.*),$1,see;__END__
> s,^(.*3),,mg,@_=mapsplit;{#>J~.>_an~>>e~......>r~
> $_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
> '%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
> print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-

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

Similar ThreadsPosted
(C++) Class Member Function January 24, 2005, 11:56 pm
member callback function July 11, 2005, 3:01 pm
filehandle to a member of a zip archive June 3, 2006, 4:14 pm
Archive::Zip - is a member directory ? December 14, 2006, 9:35 am
Object Member List Instances June 23, 2005, 4:32 pm
dynamically adding member sub to object? November 1, 2005, 9:15 pm
hash on private member variable November 28, 2005, 12:01 am
How to find which (if any) member of a list is in a given line of text July 18, 2006, 11:08 am
Photo re-sizing code for member-base web site October 13, 2005, 9:50 pm
Dave Roth's site (Win32::AdminMisc, Win32::ODBC, etc.) not available. December 22, 2005, 7:38 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap