Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I open the command prompt, it automatically closes itself after 2-3 seconds. Can anyone help me why Command Prompt in Windows 7 automatically hides after 2-3 seconds?

share|improve this question

migrated from stackoverflow.com Aug 3 '10 at 11:58

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

You could have a virus running on the system that is closing the command prompt, in order to make it more difficult for you to remove the virus.

Perhaps it is killing processes that are named cmd.exe. I suggest that you make a copy of cmd.exe and call it abcd.exe. Then run abcd.exe and see if it keeps running.

share|improve this answer
2  
+1, I've only seen this behaviour when I've had some virus. Also try to run Regedit and see if it does the same. –  Hondalex Aug 3 '10 at 14:16
    
I have seen this virus on XP. Didn't expect to see this one on 7. –  user May 15 '11 at 8:20
add comment

If you are writing a program that executes on the command line, and running it directly from your IDE, not by typing the program name in manually, the command prompt window will close as soon as the program finishes executing. To avoid this, either manually open a command prompt, entering the executable name to run it, or stick a getchar call or equivalent at the end of your program.

share|improve this answer
    
I have just opened the command prompt by writing cmd.exe. When it opens up after 2-3 seconds it automatically close by itself don't know why? –  Rashim Aug 3 '10 at 7:31
add comment

Are you using Windows 7 build 7000 ? According to this topic, there are known bugs in that build for command prompt and network drives. You can check build version by opening up cmd, see image :

enter image description here

As you see my windows 7 build version is 7601. The lastest version so far. So if your version is before 7601, I suggest you to update to the lastest version.

share|improve this answer
add comment

Your Answer

 
discard

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