Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error in Win32::OLE script

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
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


Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top