14

I'm in the middle of running a batch script that's taking a really long time and whose output is whizzing by at an unreadable rate. Is there a keyboard shortcut that allows you to pause the CMD console where it currently is to stop and read the output, and then re-start it again from the same place?

enter image description here

  • 5
    There's always CTRL-S. Then CTRL-Q to re-start. – BillP3rd Nov 14 '16 at 3:15
  • You can grab the scroll box and move it up, this will effectively pause the scrolling. You can then hit the down arrow key to move to the bottom of the buffer. – Burhan Khalid Nov 14 '16 at 5:12
  • Isn't this the intended purpose of the "Scroll Lock" key? – TOOGAM Nov 26 '16 at 1:57
5

I didn't see this in the other answers.

I believe the serial control sequences of 'Ctrl-S' XOFF and 'Ctrl-Q' XON are the key sequences intended to solve the issue.

Please see;

XON/XOFF

  • 1
    I changed this to best answer for a few reasons. From research, the Pause/Break key on its own halts output, but not execution, which the other answer makes no mention of. Ctrl + Pause/Break must be used to halt execution, and this is slightly more cumbersome to type on most keyboards than Ctrl+S and Ctrl+Q (can be done with solely the left hand). That said, Ctrl + Pause/Break has the advantage that it doesn't need you to remember two extra keybindings, so both answers are good, I'd just like to see this one get the upvotes it deserves. – Hashim Mar 6 '18 at 23:24
  • Note that although this answer sources a Unix/Linux question, the keybindings work fine on CMD.exe, at least on my Windows 7 OS. – Hashim Mar 6 '18 at 23:26
  • 1
    @Hashim, thanks for sharing your research. Because you specifically asked how to pause output, I didn't consider (nor tested) this possibility, but it is nice to learn of. (Upvoted) – Marc.2377 Feb 15 '19 at 21:31
16

Does your keyboard contain the Pause/Break key? It would serve well for this. Here's what it looks like, or at least used to:

Pause Break Key from Wikipedia

As an interesting bonus, this key can also be used during POST (Power On Self Test, which runs when the computer is turned on) to read output from the BIOS.

If you don't have that key, the combination Control + NumLock should work just the same, and there are other options depending on your manufacturer, according to Wikipedia.

To resume execution, press Enter.

  • Note on some keyboards you may have the a specific scroll lock key (usually marked ScrLk), which can serve a similar purpose. – Burhan Khalid Nov 14 '16 at 5:14
  • @BurhanKhalid Well, I read on that link that it pauses output, but not execution, and this effect seems to not apply to the MS Windows console... but cool to know nevertheless – Marc.2377 Nov 14 '16 at 5:19
  • 1
    With ping, it appears to stop execution. that's very odd, since ping is a discrete executable. additionally when paused, the ping.exe process remains in process explorer until it is allowed to complete. while paused, all its threads go into Wait:Executive, and doesn't seem to pulse periodically. Fascinating. – Frank Thomas Nov 14 '16 at 7:44
  • 2
    Another trick that i like to use is to mark some text with the mouse (i always have quickedit mode enabled). That halts output (and hence execution, since a program that writes to stdout waits until the stream is written), too. – ths Nov 14 '16 at 13:58
1

You can use "more" command. Though it is not exactly what you are looking for, it will limit screen output by a page.

  • 1
    This is the best solution because pausing the output at the right moment is pretty much impossible given the speed at which output is generally produced. For clarification you have to use a pipe after your command followed by MORE. For example NETSH HTTP SHOW SSLCERT | MORE – Vincent Jun 13 '18 at 17:43
  • Windows does not have 'more' native – KumarAnkit Apr 16 '19 at 14:59
1

Adding one more useful way for linux shells. (But maybe ok in windows too, try it!)

Presssing ctrl+z will hang the program. (Message: stopped)

To run it back again at his previous state, like if it were paused:

Type fg

Or for multiple usage: fg program_name_previously_ctrl+z_stopped`

0

There are a couple other methods here to add, if we're being thorough:

1) In addition to the Pause/Break button you can duplicate it's functionality by Using "CTRL+C".

This will cause the cmd script to pause and ask you if you would like to terminate it. Once you are done looking you can select "NO" (or perhaps yes if it suits you) and it will continue (Or exit, if you chose yes).

2) You can ALSO pause using the mouse by clicking your mouse cursor in the window to select text from the CMD Terminal.

You may have noticed this pausing output in the past and thought only the output to be delayed, however when scripts are running in interactive cmd instances you are actually pausing the execution of the code (The same as with "Pause/Break" and "CTRL+C" Methods).

However once the window loses focus, or you click to unpause things, the code execution will continue, and you have no option to end the code through this manner.

  • Wow, you guys are young. Never used serial terminals? Try Ctrl-s/Ctrl-Q – NetScr1be Mar 7 '18 at 0:08
  • Terminal emulator software generally implements XOFF/XON support as a basic function. This generally includes the system console on modern Unix and Linux machines, as well as GUI emulators such as xterm and the Win32 console. – NetScr1be Mar 7 '18 at 0:09
0

On windows systems, if the output screen has enabled Quick Edit Mode (by Configuration) just click on the screen and select any part of the screen. The program will stop execution until you right-click on the screen to un-select. The screen can lose focus and it will continue to be frozen until you come back and right click on it. Beware that any content of the Clipboard, if any, can be turned over that screen when you right click on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.