0

After spending an hour on Googling for a shortcut, I have to ask here: How can I clear the scrollback buffer and history in the Windows console, while a program is running? Like CMD's cls command does.

Background: I have a program that spams the command line, but I can not restart the program during my test runs.

Windows offers shortcuts to change the opacity of the window but no shortcuts to clear scrollback buffer?!

Thanks

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
Squelsh
  • 101
  • 1
  • 6
  • Can't you add that functionality to the program itself? – yotabyte Oct 16 '17 at 12:50
  • This might be a bit of a workaround, but could you pipe the output to a file while your program is running to keep the console window clean? – Spangen Oct 16 '17 at 12:54
  • @Yotam Hmm, the program is multi OS, and I do not want to implement Windows console specific stuff, which is part of the job of the console itself (: – Squelsh Oct 16 '17 at 13:09
  • You could try to run another program simultaneously that periodically calls the cls command. This is done using the "start" command like [here](https://stackoverflow.com/questions/6487766/how-to-start-2-programs-simultaniously-in-windows-command-prompt). – yotabyte Oct 16 '17 at 13:43
  • Console applications either inherit or allocate a console (conhost.exe) and in general they do not run from CMD. For example, powershell.exe is a console UI shell, and netsh.exe is a console UI shell for network commands. So you would need to write a GUI app that can attach to any console via `AttachConsole` and clear the active screen buffer. – Eryk Sun Oct 16 '17 at 14:04
  • @eryksun Thanks a lot for clarification and correcting my question! I will investigate in your proposed method. – Squelsh Oct 17 '17 at 12:38

0 Answers0