Restore buffer on exit /b [Closed]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Restore buffer on exit /b [Closed]

#1 Post by atfon » 16 Nov 2021 13:41

Edit: Please disregard.I had previously turned off the cursor with a terminal escape sequence. The powershell command works fine.

I have a script which changes the console screen height and width periodically with the mode con command. I'd like to reset it back to the defaults on exit /b. I can use this:

Code: Select all

mode con: cols=120 lines=30
If I do this, I lose the default buffer. Is there any way to restore the buffer?

I can use powershell:

Code: Select all

powershell -command "&{$w=(get-host).ui.rawui;$w.buffersize=@{width=120;height=9001};$w.windowsize=@{width=120;height=30};}"
However, I find that my cursor stops blinking.

[Win 10 Pro]

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Restore buffer on exit /b [Closed]

#2 Post by aGerman » 16 Nov 2021 14:26

The PowerShell command works flawlessly for me, Win11 Home.
// EDIT Didn't see your update :lol:

I tried to use an alternate screen buffer, resize it, and later turn back to the original buffer.
https://docs.microsoft.com/en-us/window ... een-buffer
However, updating the size of the alternate buffer doesn't seem to be supported.

Steffen

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Restore buffer on exit /b [Closed]

#3 Post by atfon » 16 Nov 2021 14:47

aGerman wrote:
16 Nov 2021 14:26
I tried to use an alternate screen buffer, resize it, and later turn back to the original buffer.
https://docs.microsoft.com/en-us/window ... een-buffer
However, updating the size of the alternate buffer doesn't seem to be supported.

Steffen
Thank you for testing the Terminal Escape Sequences with the buffer. I was just getting to that myself! :)

Post Reply