Use the programm below and start it with perl WMI-GENERIC.PL <your servername> Win32_Process
# perl wmi-generic.pl computername Win32_ComputerSystem computername2 Win32_Processor # *And lastly, the asterisk can be used when looking for local computer information # perl wmi-generic.pl * Win32_ComputerSystem computername2 Win32_Processor foreach $item (@ARGV) { $x++; if ($x == 1) { if ($item eq "*") { $name = Win32::NodeName(); } else { $name = $item; } } elsif ($x == 2) { WMI($name,$item); $x=0; } } sub WMI { my $Computername = $_[0]; my $Win32_Class = $_[1]; my $Class = "WinMgmts://$Computername"; my $Wmi = Win32::OLE->GetObject ($Class); print "$Computername ($Win32_Class)-> "; if ($Wmi) { my $Computers = $Wmi->ExecQuery("SELECT * FROM $Win32_Class"); if (scalar(in($Computers)) lt "1") { print "\n Check the computer and class name.\n"; print " No information was found on the specified class!\n"; return 0; } print "$Computername\n"; foreach my $pc (in ($Computers)) { properties($pc); } } else { print "Unable to talk to WMI (Maybe I should ping this box instead of assuming it is alive? :) )\n"; } } sub properties { my $node = $_[0]; foreach my $object (in $node->{Properties_}) { if (ref($object->{Value}) eq "ARRAY") { print " $object->{Name} = { "; foreach my $value (in($object->{Value}) ) { print "$value "; } print "}\n"; } else { print " $object->{Name} = $object->{Value}\n"; } } print "----------------------------------\n"; } Mit freundlichen Grüßen i.A. Manfred Maier ------------------------------------ Karl Miller GmbH, Dettinger Str. 13, 88486 Kirchberg Manfred Maier, Leiter EDV Telefon: 07354 / 886-447 Fax: 07354 / 886-100 Email: [EMAIL PROTECTED] www.kmk-miller.de ------------------------------------ -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:marms@;sandia.gov] Gesendet: Freitag, 8. November 2002 01:49 An: 'Nguon,Vath'; '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Betreff: RE: GetPID First off let me say that I've been looking for something like the code below which lists all processes running on a Win32 machine for a bit. But I've probed around with Data::Dumper and cannot see from the code below, how $Proc (a hashref) has entries for: $Proc->{ProcessID} $Proc->{Name} $Proc->{ExecutablePath} As far as I can see, these keys do not exist in the hashref of $Proc, but there's something going on here as indeed they do produce exactly what they are named for. Can someone explain this? What other information can we extract from $Proc (other hidden keys)? Documentation? -- Mike Arms -----Original Message----- From: Nguon, Vath [mailto:NguonV@;MTA.NET] Sent: Thursday, November 07, 2002 1:17 PM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: GetPID The following Perl script was extracted from Dave Roth's Books. It should run on Win2k machine. ======================================================================== == use Win32::OLE qw( in ); $Machine = ""; # Null string default to local machine $CLASS = "WinMgmts:{impersonationLevel=impersonate}!//$Machine"; $WMI = Win32::OLE->GetObject($CLASS) || die "Unable to connect to \\$Machine". Win32::OLE->LastError(); $ProcList = $WMI->InstancesOf("Win32_Process"); print "\n********************************************************************* **** **\n"; print " Running Processes on Server ".uc($Machine)."\n"; print "*********************************************************************** **** \n\n"; foreach $Proc (in( $ProcList )) { print $Proc->{ProcessID}."\t"; print $Proc->{Name}."\t"; print $Proc->{ExecutablePath}."\n"; }#foreach $proc print "\n********************************************************************* **** **\n\n"; undef $ProcList; print "\nEnd of program..\n"; _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs To: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs