use strict; use Win32::OLE; my $WMI = Win32::OLE->GetObject("winmgmts:"); my $Procs = $WMI->InstancesOf("Win32_Process"); foreach my $Proc (in $Procs) { printf( "PID %u has %u threads.\n", $Proc->ProcessId, $Proc->ThreadCount, ); }