Hi experts
!
A little time ago
one of you send the following script :
***************************************************************************************************************
use
Getopt::Long;
use Pod::Usage;
use Win32::OLE;
use Pod::Usage;
use Win32::OLE;
my ($class) =
"Win32_Process";
# Bomb out
completely if COM engine encounters any trouble.
Win32::OLE->Option ('Warn' => 3);
Win32::OLE->Option ('Warn' => 3);
# Get a handle to
the SWbemServices object of the machine.
my $computer = Win32::OLE->GetObject (exists $opts{'remote'}
? "WinMgmts://$opts{'remote'}/"
: 'WinMgmts:');
my $computer = Win32::OLE->GetObject (exists $opts{'remote'}
? "WinMgmts://$opts{'remote'}/"
: 'WinMgmts:');
# Get the
SWbemObjectSet of all objects of the class.
my $instances_set = $computer->InstancesOf ($class);
my $instances_set = $computer->InstancesOf ($class);
# Convert set to
Perl array.
my @instances = Win32::OLE::Enum->All ($instances_set);
my @instances = Win32::OLE::Enum->All ($instances_set);
# Display all
properties of an object.
sub dump_obj ($) {
my ($obj) = @_;
# Get set of properties of the class.
my $props_set = $obj->{'Properties_'};
sub dump_obj ($) {
my ($obj) = @_;
# Get set of properties of the class.
my $props_set = $obj->{'Properties_'};
#
Convert set to Perl array.
my @props = Win32::OLE::Enum->All ($props_set);
$test = 0;
foreach my $prop (@props) {
my $name = $prop->{'Name'};
printf "%32s ", $name;
my $value;
if ($prop->{'IsArray'}) {
$value = '<array>';
}
else {
$value = $prop->{'Value'};
defined $value
or $value = '<undefined>';
}
print "$value\n";
if (($name eq "Name")&&($value eq "wfica32.exe")) {
$test = 1;
}
if (($test == 1)&&($name eq "ProcessId")) {
$result = $value;
}
}
return($result);
}
my @props = Win32::OLE::Enum->All ($props_set);
$test = 0;
foreach my $prop (@props) {
my $name = $prop->{'Name'};
printf "%32s ", $name;
my $value;
if ($prop->{'IsArray'}) {
$value = '<array>';
}
else {
$value = $prop->{'Value'};
defined $value
or $value = '<undefined>';
}
print "$value\n";
if (($name eq "Name")&&($value eq "wfica32.exe")) {
$test = 1;
}
if (($test == 1)&&($name eq "ProcessId")) {
$result = $value;
}
}
return($result);
}
foreach my $instance
(@instances) {
$res = dump_obj ($instance);
print "\n";
push(@result, $res);
}
print @result;
exit 0;
$res = dump_obj ($instance);
print "\n";
push(@result, $res);
}
print @result;
exit 0;
********************************************************************************************************
It works very fine
on my computer (workstation Win 2000), but as soon as I run it on a server of my
network (Nt4 server), it returns Win32::OLE errors (lines in red)
:
WIn32::OLE(0.1601)
error 0x800401e4 "syntaxe non valide" after caracter 0 in "WinMgmts:",
eval{...} called
Does anyone have
ideas about it ?? Does it come from a difference of classes (Win32_Process) in
the 2 OS or else???
Thanks so
much...
