Richhh_y
Richhh_y

Reputation: 79

Disabling resize?

I'd like to know how to disable terminal window's resizing? I mean, so user cannot drag a side or corner of the terminal and it didn't change the resolution of the window.

Hope you all understand.

Upvotes: 1

Views: 1363

Answers (1)

shadow2020
shadow2020

Reputation: 1351

Here is what I came up with:

@echo off

FOR /F "delims=" %%G in ('powershell.exe -executionpolicy unrestricted $host.UI.RawUI.WindowSize.Height') do SET height=%%G
echo %height%

IF /I "%height%" GEQ "37" mode con: cols=100 lines=37
IF /I "%height%" LEQ "36" mode con: cols=100 lines=37

pause

This part uses powershell in it in order to figure out the CMD window height. It then puts it into variable %height%.

IF /I "%height%" GEQ "37" mode con: cols=100 lines=37

This part says ok if the height we found is greater than or equal to 37 then lets change the buffersize/window size to 37.

IF /I "%height%" LEQ "36" mode con: cols=100 lines=37

This part says if the height we found is less than or equal to 36 then lets change the buffersize/window size to 37.

You could do a .bat file with this code in it (call is resize.bat) and at the end do: exit /b

Then from your main .bat file you can do call resize.bat Then just reference that as often as needed to check the size and resize it.


As far as outright disabling it, I don't think you can. Furthermore, people rarely resize a cmd window as there isn't much of a point.

Upvotes: 3

Related Questions