I converted a VB Script with the Perl Dev Kit VB Script convertor.  Having
problems with one statement.  The script uses Win32::OLE to connect to WMI,
delete a class if it exists; (re)creates the class; and finally sets the key
field.  That is were it is failing with a error msg:

*Can't call method "Value" on an undefined value at noname.pl line 39.*


use  Win32::OLE qw(in);

my $_app_object = (Win32::OLE->GetActiveObject('WScript.Shell') ||
                  Win32::OLE->new('WScript.Shell'));

use strict;

use constant wbemCimtypeString => 8;
my ($oLocation, $oServices, $oInstances, $oObject, $oDataObject,
$oNewObject);

$oLocation = Win32::OLE->new('WbemScripting.SWbemLocator');

# Remove class'
$oServices = $oLocation->ConnectServer('root\\cimv2');
$oNewObject = $oServices->Get('GT1FIND');
$oNewObject->Delete_();


# Create data class structure '
$oServices = $oLocation->ConnectServer(undef, 'root\\cimv2');
$oDataObject = $oServices->Get;
$oDataObject->Path_->{Class} = 'GT1FIND';
$oDataObject->Properties_->Add('SystemName', wbemCimtypeString)->Value;
$oDataObject->Properties_->Add('Condition', wbemCimtypeString)->Value;
$oDataObject->Properties_->Add('FullPath', wbemCimtypeString)->Value;
$oDataObject->Properties_->Add('Filename', wbemCimtypeString)->Value;
$oDataObject->Properties_->Add('Filesize', wbemCimtypeString)->Value;

# Following line fails
$oDataObject->Properties_('FullPath')->Qualifiers_->Add('key', 1)->Value;


$oDataObject->Put_()->Path;

Any ideas?

Thanks
_______________________________________________
Perl-Win32-Admin mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to