Why is my command prompt freezing on Windows 10?

Command LineWindows 10Command PromptFreeze

Command Line Problem Overview


I'm adding this question after spending an entire day wrestling with this incredibly frustrating feature of the Windows 10 command prompt which made me think there was something wrong with my console application code. I hope it will help someone.

Issue: My console application seems to randomly stop running. What is going on?

Command Line Solutions


Solution 1 - Command Line

The issue ended up being a new feature of the windows 10 console. Under the default config, whenever you click on a command window in windows 10, it immediately halts the application process when it attempts to write to the console. When this happens, the command window has gone into "selection" mode.

You can tell it has happened because it will prefix the title bar of the command window with the word "Select" :

frozen command window

To get your program running again, you have to press escape or click somewhere else.

To get rid of this strange behavior, you can disable QuickEdit mode:

disable QuickEdit Mode

Solution 2 - Command Line

What I'd like to add here to Shaun Rowan's answer is that for it to work in all console windows you have to click "Defaults", instead of "Properties" and make your changes there, as described in this post.

Solution 3 - Command Line

I faced this problem very recently where one of the users (who had Quickedit configured on his Command Prompt) was using a tool I developed in Java, and was getting the tool frozen while running it from command prompt.

Finally what solved the problem was to redirect the logging inside the batch script to a file as shown below:

@echo off
...
java.exe -jar mytool.jar

needed to be updated to

java.exe -jar mytool.jar > log.txt

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShaun RowanView Question on Stackoverflow
Solution 1 - Command LineShaun RowanView Answer on Stackoverflow
Solution 2 - Command Lineiko79View Answer on Stackoverflow
Solution 3 - Command LinePriyankuView Answer on Stackoverflow