I am trying to create an app which monitors for process creation/termination and logs the amount of time it executed and its frequency which is finally being logged in mysql db. The problem that I am facing is that, I am using Win32_ProcessStartTrace and Win32_ProcessStopTrace for monitoring. As soon a process is created, its commandline is being queried using Win32_Process. There seems to be a “lag” between Process creation and the querying of its commandline for those processes which exit quickly so I can’t get the commandline.
Is there any way of getting this done?
This code watches for new processes starting and prints the command line used: