Does anyone come across a scenario when the command prompt is running a process and then it gets stuck and the process is also sleeping. Then when we press Enter key in the cmd window the process continues.
Is there any way to avoid this? or can this be handled??
One reason why you're unable to run the command prompt on your computer is that there might be a third party software causing conflict to it. For us to assist you, we suggest that you start your PC in safe mode.
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.
Press Win + R to open the Run box, then type "cmd" and hit Enter to open it.
Then we hit Ctrl+C to terminate the execution.
The other answers are wrong! The Windows console has a separate mode called "mark mode" for selecting text. In that mode the screen will be frozen, texts will go into the buffer and if the buffer is full the running process will be blocked
If quick edit 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. Priority is absolutely irrelevant here because if the buffer is full then the process is blocked forever until you exit mark mode, regardless of the priority. The console does nothing to change the priority when there are some inputs. Try opening an app that outputs a lot of data in the highest priority and click the console, the app will still be blocked indefinitely even if the CPU is in idle
Here's an example of QuickEdit mode setting in Windows 8 console:
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
If other processes are sucking all the cycles and have a higher prio, then your process might be stopped. A user input might just give it a prio boost, so it starts again. See Microsoft Docs at https://docs.microsoft.com/en-us/windows/win32/procthread/priority-boosts for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With