use Win32::OLE qw(EVENTS); use Win32::Console; use Data::Dumper; my $refWMI = Win32::OLE->GetObject('winMgmts:'); my $refSink = Win32::OLE->CreateObject('WbemScripting.SWbemSink', "SINK_"); my $strQuery = "SELECT * FROM __InstanceCreationEvent" & " WITHIN .1 WHERE TargetInstance ISA 'Win32_Process'"; $refWMI->ExecNotificationQueryAsync($refSink, $strQuery); while (true){ sleep 1; print "Sleeping to keep the script alive...\n"; } $count = 1; sub SINK_OnObjectReady{ print "Ready\n"; } sub SINK_OnCompleted{ print "Done\n"; }