Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes I find myself in a cmd.exe environment that itself was started by another cmd.exe or by another console-based application. Now, working in such an environment, I'd like to know what happens if I type exit, that is, if the cmd.exe window will disappear, or if it goes back to the creating cmd.exe or application. This, of course, because sometimes as I work in cmd.exe I am forgetful about how I called it.

So, is there a way to find out the parent process (if this is the correct terminus for what I mean) of a cmd.exe within cmd.exe?

share|improve this question
"parent process" is correct terminology, but i don't think "terminus" is... – quack quixote Mar 17 '10 at 7:33

2 Answers

You can use WMI to get this information. The Win32_Process class contains ParentProcessId

So (using PowerShell to execute WMI commands—other WMI tools are available):

gwmi Win32_Process -filter 'processid = 1234' | select ParentProcessId

will give the parent process id of process 1234.

share|improve this answer
I haven't tried this, but this sounds correct. Upvoted. – Alexander Burke Mar 18 '10 at 4:59

This isn't from within cmd.exe itself but Process Explorer has a tree view which shows parent processes.

alt text

share|improve this answer
1  
Yes, this is certainly correct, but I hoped there would be some command or something that I could type into cmd.exe. – René Nyffenegger Mar 16 '10 at 9:41
1  
another SysInternals tool, pslist.exe, can also provide a tree view. unfortunately PPID (parent process ID) is not part of the general output, but if the cmd window was started by another application the tree view should show that relationship. technet.microsoft.com/en-us/sysinternals/bb896682.aspx – quack quixote Mar 17 '10 at 7:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.