mmanring has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have a program that I have recently added some functionality from the Win32::OLE module to. This is contained within a function which looks like this:
------------------------------------------------------------
sub checkSEINPerformance { my $objWMI = Win32::OLE->GetObject('winmgmts://' . $strComputer . +'/root/cimv2'); my $colProcesses = $objWMI->InstancesOf('Win32_Process'); foreach my $objProcess (in $colProcesses) { if ($objProcess->Name =~ /SEINPerformance/) { return $objProcess->ProcessID; } } return -1; }
------------------------------------------------------------
The strComputer variable was defined in the beginning of the program to be ".", the local system. Also, I have set the $Win32::OLE::Warn variable to be 3. When my program gets to the first line of this function, it gives me the following error:
Win32::OLE(0.1701) error 0x80070422: "The service cannot be started, either because it is disabled or because it has no enabled devices associated with it" after character 0 in "winmgmts://.root/cimv2" ....
...and it goes on to list line numbers and the such. If anyone can help it would me much appreciated.

Thanks,
Michael

Replies are listed 'Best First'.
Re: Win32::OLE module not working
by NetWallah (Canon) on Jan 22, 2008 at 17:27 UTC
Re: Win32::OLE module not working
by InfiniteSilence (Curate) on Jan 22, 2008 at 16:59 UTC
    Hmmmm...dunno. Works for me on a Vista machine (of couse, I don't have that process running on it):
    use Win32::OLE; my $strComputer = qw|.|; &checkSEINPerformance; sub checkSEINPerformance { my $objWMI = Win32::OLE->GetObject('winmgmts://' . $strComputer . +'/root/cimv2'); my $colProcesses = $objWMI->InstancesOf('Win32_Process'); foreach my $objProcess (in $colProcesses) { if ($objProcess->Name =~ /SEINPerformance/) { return $objProcess->ProcessID; } else { print qq|NOT IT: | . $objProcess->Name . qq|\t| . $objProcess->ProcessID . qq|\n|; } } return -1; } 1;
    I get:
    NOT IT: System Idle Process 0 NOT IT: System 4 NOT IT: smss.exe 480 NOT IT: csrss.exe 544 NOT IT: wininit.exe 592 ...

    Celebrate Intellectual Diversity