71

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.

13
  • 2
    Any of these machines set to sleep at all?
    – Windos
    Jul 18, 2011 at 23:04
  • 1
    It sounds like you're having the same issue from two completely different environments (Linux and Windows). So you might ask what do these two things have in common? Is it the same script/code? Copying to the same server?
    – Nixphoe
    Jul 19, 2011 at 1:54
  • 3
    Those who are wondering if it is still an issue,Yes ! Dec 31, 2019 at 6:52
  • 8
    Still a problem in 2020
    – Bakhshi
    Jun 17, 2020 at 4:08
  • 5
    Still a problem in 2022! Apr 1, 2022 at 14:49

3 Answers 3

41

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.

4
  • 1
    I have quick edit mode off, and experience this often in node. No issues on linux. But windows will seem to pause, until I ctr C once. This continues the node process. Seems like it would kill the process if it was truly hanging.
    – edencorbin
    Sep 5, 2018 at 23:14
  • I have disabled quick edit mode so will keep an eye. My solution is to resize my cmd prompt, or power shell window a bit - to get the npm script to continue. Very strange indeed.
    – shanehoban
    Feb 28, 2019 at 23:07
  • 9
    I've seen this for 20 years in windows. It has appeared and disappeared many times... I think its Microsoft not doing proper regression testing, because it comes and goes every few years
    – gunslingor
    Oct 11, 2019 at 16:38
  • 1
    Experiencing this regularly these days when running python3.7 scripts in powershell, very annoying :(
    – Loknar
    Dec 18, 2019 at 12:22
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

-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
2
  • If you found a question, with an answer that answers this question, you should flag it as a duplicate. We try to avoid answers that just point to another answer.
    – Ramhound
    Sep 29, 2021 at 22:51
  • 2
    Until someone flags the question as a duplicate, it's still good to have an answer here. It's a 10 year old question with 40k views and otherwise no clear answer so far. The downvotes on a potential solution make no sense for someone coming from Google.
    – Blaisem
    Oct 29, 2021 at 11:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .