Win32::OLE error in thread (ActiveSatate 5.8) on XP

M

MoshiachNow

HI,

Get error in the following scripts that gets a list of all installed
SW:

use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root
\\CIMV2") or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM
Win32_ProductSoftwareFeatures", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems) {
print STDOUT "objitem=$objItem=\n";
my $product1=$objItem->{Product};
$product1 =~ s/.*Name=\"(.*)\"/$1/;
$product1 =~ s/\"//g;
$products->{$product1}="YES";
}


The error is on one of the items in hash:

Win32::OLE(0.1707): GetOleEnumObject() Not a Win32::OLE::Enum object
at D:/Perl/lib/Win32/OLE/L
ite.pm line 167.

I guess that something is wrong with one of the returned hashes.
How do I skip the bad entry and get only valid entries?
Thanks
 
M

MoshiachNow

HI,

Get error in the following scripts that gets a list of all installed
SW:

use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root
\\CIMV2") or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM
Win32_ProductSoftwareFeatures", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems) {
print STDOUT "objitem=$objItem=\n";
my $product1=$objItem->{Product};
$product1 =~ s/.*Name=\"(.*)\"/$1/;
$product1 =~ s/\"//g;
$products->{$product1}="YES";

}

The error is on one of the items in hash:

Win32::OLE(0.1707): GetOleEnumObject() Not a Win32::OLE::Enum object
at D:/Perl/lib/Win32/OLE/L
ite.pm line 167.

I guess that something is wrong with one of the returned hashes.
How do I skip the bad entry and get only valid entries?
Thanks

I will appreciate any help on this one.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top