Windows: Find out which process spawned another process

powershellwindowswindows-command-promptwindows-server-2008

I have a situation with processes a bit like below. We have 2 executables, foo.exe and bar.exe. bar.exe is always launched by foo.exe.
I want to know how to find out which bar.exe has been spawned by which foo.exe. It's probably very simple but cannot work it out.

Name      Pid

foo.exe   1
foo.exe   2
foo.exe   3

bar.exe   4
bar.exe   5
bar.exe   6

Happy for dos or powershell solutions.

Best Answer

You can use wmic process get Caption,ParentProcessId,ProcessId for a list in command line. Or use Process Explorer from the SysInternals Suite for a GUI option.