75

Problem:

For some reason once in a while my command prompt would hang until I press a random key, and it would continue operation as if nothing happened.

Occurrence:

This happens when I am running a long operation (such as building/compiling some code). When it hangs, it gives no indication of what's going on nor does it prompt me to press any key.

Description:

  1. After a couple minutes, the terminal stops printing out the progress, and gets stuck.
  2. I had thought that it was simply stuck on a very lengthy portion of the compile process, but after a few hours it was still stuck on the exact same place.
  3. I pressed a random key, and it suddenly jumped straight back and continued spewing out progress indicators and continued working.

After this, similar events have happened many times during lengthy processes, such as copying files.

This has happened on multiple devices running windows 7. It has also occurred on Ubuntu using bash shell.

phuclv
  • 30,396
  • 15
  • 136
  • 260
Razor Storm
  • 1,039

3 Answers3

42

I have experienced the same issue. Answers here and here indicate this is likely an issue with Quick Edit mode in the console. If it intercepts stray mouse clicks, or if clicks get passed erroneously through RDP, for instance, it can unintentionally pause the script. You can right-click the menubar and edit properties to turn off Quick Edit mode. That, of course, makes it more difficult to copy and paste out of the CMD window.

Tim D
  • 529
5

The old Windows console has a separate mode called "mark mode" for selecting text. In that mode the screen will be frozen for ease of selection

Mark mode

If QuickEdit mode is enabled (by default it's disabled in older Windows but enabled in Windows 10) then clicking inside the console window will activate mark mode and result in what you observed

It's very easy to accidentally click the console and stop the command. When you press Enter or Esc the selected text will be copied to clipboard and mark mode will be exited, therefore the process will run again

Here's an example of QuickEdit mode setting in Windows 8 console:

cmd

To fix this you can disable QuickEdit mode if you don't need it. In this case copying will be more troublesome because you must open the context menu, select Edit > Mark. You can also disable QuickEdit mode by setting ENABLE_QUICK_EDIT_MODE with SetConsoleMode() if you're writing your own console application

But the better solution is to use Windows Terminal which is significantly better, faster, more featureful and more powerful

See also

phuclv
  • 30,396
  • 15
  • 136
  • 260
-1

I found this answer, and it works for me on Windows 10 20H2. The trick seems to be,

powercfg -change -standby-timeout-ac 0
horaceT
  • 115