Infosys Microsoft Alliance and Solutions blog

« WPF: Working with command line arguments | Main | Cloud computing made possible with Azure »

Command prompt instance counting

Here's something that I accidently noticed today. Inside of a command prompt, of you type "cmd" (to launch  a commonad prompt), it treats this as a new instance, though no new windows is opened. Now if you type "exit", the command window still stays since there were effectively two instances. Only when you type "exit" the second time, will the command window close.

This can go on at any level (I didn't really try too many levels). You can also easily make out the # instances by looking at the title bar. Every time you type "cmd" at a command prompt, you will see "- cmd" get added to the title. With every "exit" one of these goes away till you are back to the default title you had started up with and another "exit" will close the window.


That's a great observation Atul. But after I tried it, I realized it the same thing as Unix does. If you are in ksh and you type bash then you will return to ksh again once you enter exit in bash.

The core reason for this is, the shell (in unix) or command (in windows) and programs which are self recursive. They can run within themselves. So that is why multiple instances can happen this way.

Nitin, thanks for the explanation.

Would there be any provision to make the new instances as a separate one?

Jyothikarthik, if you mean new instance as a new window, then i guess you can just get back to start/run and start a new instance as you started the first one.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter