Solved Disabling window resize in batch file

Various / HOME BUILT
July 31, 2017 at 05:59:09
Specs: Windows 10 Pro x64, Intel i7 6700k, 32GB 3200MHz DDR4 RAM
I'm trying to make a UI for my batch script with multiple colors, which works great. However when the window is resized it messes up everything. I'm trying to disable it through PowerShell with a one-liner, but since I know nothing about PS I don't really know what I'm doing.

Right now I'm trying this but it doesn't limit the window size. It does set the buffer sizes correctly though:

powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%~3;$B.height=%~4;$W.buffersize=$B;}"
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$W.maxphyscalwindowsize.width=%~3;$W.maxphysicalwindowsize.height=%~4;}"

Could anyone tell me what I'm doing wrong and perhaps point me in the right direction, or tell if it's doable at all?

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

message edited by RainBawZ

See More: Disabling window resize in batch file

Reply ↓  Report •

August 1, 2017 at 11:04:03
✔ Best Answer
You really can't; it's not your window to begin with. It belongs to conhost.exe or csrss.exe (depending on your Windows version). You could use PowerShell to use C# to use P/Invoke to strip the resizable boarders and the min/max buttons, but it's complicated, it gets messy quickly, and you can't stop people from using the Properties window.

You might need to just trust that your users want to use your script, and not looking to break it. Alternatively, you could just embrace a programming language that allows you to use the Windows GUI, and leave the frustrations of batch behind. I recommend C#, but there are plenty of options out there.

How To Ask Questions The Smart Way

Reply ↓  Report •
Related Solutions

Ask Question