Here is a simple script I wrote that works fine when stepped throguh with the PDK debugger, but when run without the -d switch, I get this error:
 
Win32::OLE(0.1704): GetOleEnumObject() Not a Win32::OLE::Enum object at C:/Perl/site/lib/Win32/OLE/Lite.pm line 167.
 
I've seen something similar when stepping through the app and hitting an OLE statement, but this is a first.  Limited life experiences I guess.  Any ideas?  Thanks.
 
use strict;
use Win32::OLE('in');
use Win32::Process;
 
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
 
my $computer = Win32::NodeName();my $App_Count = 0;
 
my $objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Process", "WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);
 
my @Watched_Apps = ("shstat.exe","kix32.exe","cmd.exe");my $event;my $watched_app;
 
print "Scanning Processes.....";
 
while() {
 
 foreach my $objItem (in $colItems) {
      
    #print "Caption: $objItem->{Caption}   ProcessId: $objItem->{ProcessId}\n";
        
     foreach $watched_app ( @Watched_Apps ) {
        
      if (lc($objItem->{Caption}) eq lc($watched_app)) {
          
         print "Attempting to remove app $objItem->{Caption} with PID $objItem->{ProcessId}\n";
       
         if(Win32::Process::KillProcess( $objItem->{ProcessId}, $event )) {
        
            print $event."\n";
        
            $App_Count++;
        
            if($App_Count == @Watched_Apps) {
         
            exit(0)
           
            }
           
         }
           
      }          
          
     }
          
 }
 
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to