Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Win32::OLE "Member not found"

Reply
Thread Tools

Win32::OLE "Member not found"

 
 
Adam.L.MacKinnon@gmail.com
Guest
Posts: n/a
 
      04-03-2008
Hi,

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

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

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

my %args;

$args{name} = 'TESTVAR';
$args{value} = 'TESTVALUE';
$args{target} = '.';

set_env_var(\%args);

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

my $objVarClass = Win32::OLE->GetObject('winmgmts://' .
$strComputer . '/root/cimv2:Win32_Environment');
my $objVar = $objVarClass->SpawnInstanceobjVar->Name eq
$strVarName;
$objVar->{VariableValue} = $strVarValue;
$objVar->{UserName} = '<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
 
Reply With Quote
 
 
 
 
Thomas Kratz
Guest
Posts: n/a
 
      04-08-2008
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:umper;
> use Win32::OLE;
> $Win32::OLE::Warn = 3;
>
> #use lib 'H:\dev\perl\NSLC-Store-Mgmt\lib';
> #use NSLC::Store::Mgmt;
>
> my %args;
>
> $args{name} = 'TESTVAR';
> $args{value} = 'TESTVALUE';
> $args{target} = '.';
>
> set_env_var(\%args);
>
> sub set_env_var {
> my ($args,) = @_;
> my $strVarName = $args->{name};
> my $strVarValue = $args->{value};
> my $strComputer = $args->{target};
>
> 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->{Name} = $strVarName;

> $objVar->{VariableValue} = $strVarValue;
> $objVar->{UserName} = '<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/lib...8VS.85%29.aspx

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>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^.-
 
Reply With Quote
 
 
 
 
Adam.L.MacKinnon@gmail.com
Guest
Posts: n/a
 
      04-08-2008
On Apr 8, 6:09 am, Thomas Kratz <ThomasKr...@REMOVEwebCAPS.de> wrote:
> 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:umper;
> > useWin32::OLE;
> > $Win32::OLE::Warn = 3;

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

>
> > my %args;

>
> > $args{name} = 'TESTVAR';
> > $args{value} = 'TESTVALUE';
> > $args{target} = '.';

>
> > set_env_var(\%args);

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

>
> > 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->{Name} = $strVarName;
>
> > $objVar->{VariableValue} = $strVarValue;
> > $objVar->{UserName} = '<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/lib...8VS.85%29.aspx
>
> Thomas
>
> --
> $/=$,,$_=<DATA>,s,(.*),$1,see;__END__
> s,^(.*\043),,mg,@_=map{[split'']}split;{#>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 .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To be not, or not to be not? Ruby Freak Ruby 2 09-23-2008 08:04 AM
Why not 'foo = not f' instead of 'foo = (not f or 1) and 0'? Kristian Domke Python 11 01-23-2008 07:27 PM
'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long. rote ASP .Net 2 01-23-2008 03:07 PM
Cisco 3640 3620 3600 not detecting, not enabling, not working: NM-2FE2W Taki Soho Cisco 0 09-22-2004 07:28 AM
maintaining control with cookies (not strictly an ASP or even server side question. But not not either) Stephanie Stowe ASP General 2 04-07-2004 04:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57