This question already has an answer here:
Is there a way to view or log what applications have been opening windows in my system? I have Windows 10.
My reason for wanting to do this is that I have a really annoying issue where every hour something on my system opens a command prompt window and then immediately closes it. I've scanned with Malwarebytes and it hasn't turned up anything. I've also turned on history in Task Scheduler, but no task's run time corresponds with when it happens. I'm hoping to log all the times windows are opened to figure out what is causing this.