How wmic enable horizontal scaling on command prompt window - windows

When open command prompt window. I found black fixed size windows that can scaling only vertical direction, but when i type wmic command it seem horizontal scaling also available. I just suspect what method that wmic force command prompt windows like that. Does one can explain?

A console program can change the size of the screen buffer (You can also have more than one screen buffer, but only one can be visible)
See SetConsoleScreenBufferSize()

Related

How to get scrolling back after setting width/height for cmd.exe?

I have a batch script that will display long strings of text. I want the batch script to open in a certain width, and the height at a certain height.
I have this:
MODE 200, 100
python run_program.py
The width is perfect, but now cmd.exe loses its ability to scroll vertically. I cannot scroll up to see the data unless I remove the 100 part. But if I remove the height, cmd.exe will just open up to the max height of my monitor.
I just want to open up cmd in my custom resolution: 200,100 but with scrolling. Is there any way to do that in cmd.exe?
Please note I am using ONLY the base system cmd.exe, and NOT powershell or any other console program for Windows.
Mode will set both the height/width of the console window and the screen buffer. That explains why you lose the scrollbar. You can create a shortcut to cmd.exe and in the settings of the shortcut change height/width of the cmd-windows and/or height/width of the screenbuffer.

I want to automatically fullscreen the command prompt in windows

I tried to use this code:
set WshShell = WScript.CreateObject("WScript.Shell")
WinSendKeys "%(~)"
the code works in other programms but not in cmd prompt
Are there other options to put the prompt to fullscreen via command?
Since Vista, the CMD window can't actually be made full screen (as was possible with ALT-ENTER in Windows XP); at best, you can set it to an arbitrary size in rows/columns to fit your screen size and font selection, via the shortcut properties. The buffer size properties in the shortcut must be at least as large as your proposed screen size in rows and columns, and if you set the size to larger than the screen can actually handle, you will end up with scroll bars. In any case, you can't actually suppress the title bar and border.
Launch cmd and write the following:
mode 800

Windows 10 CMD/Powershell Buffer adjusts only when enlarging the console window; not when shrinking. Fix?

I have a seemingly simple question, but my google-fu is failing me:
I have started using CMD / Powershell more in my workflow recently, for a myriad of things including VIM, compiling, and Bash (Window's Ubuntu Subsystem). These all run in window's shell interface (if that is the right term for it? As distinct from Console 2/ConEmu, which are just wrappers around the shell and don't change its behavior).
Here's my problem:
When adjusting the shell window size larger, the buffer resizes to fit it.
However, when readjusting the window size to be smaller, the buffer stays large and scroll bars appear, and I have to use the scroll bars to view my entire window.
I don't want the latter half of this behavior, as it causes problems with programs like VIM, and is just annoying.
I actually like legacy console behavior in windows 10, as though it cannot be dynamically resized, it can be minimized or maximized and the buffer resizes along with both actions. However, I cannot simply enable this option as some things such as Bash require the modern windows 10 console and won't run in legacy mode.
Are there any other ways to have the buffer resize correctly along with the size of the window for either CMD or Powershell, or alternatively, to run Powershell with different settings than CMD (so I could have legacy console enabled in one, and not in the other -- they seem to share the same settings currently).
Additionally, if there are any alternative fixes or console shells that might solve this, feel free to suggest these as well! I've tried Mintty, and it's almost perfect, but messes up my register/clipboard settings in vim.
As you've discovered, switching to the legacy console on Windows 10 (via a console shortcut's Properties dialog, tab Options, checkbox Use legacy console (requires relaunch) is, unfortunately, a global setting (affects all future console windows, irrespective of the shell run in them).
Windows 10's new console, always sets the buffer width to the window width when you resize with the mouse, avoiding the need for horizontal scrolling (whereas the legacy console retains the original, larger buffer width when you make a window narrower with the mouse, at which point a horizontal scrollbar appears; as an aside: the legacy console doesn't allow making a window wider using the mouse).
If a shortcut file of yours doesn't behave that way while not in legacy mode, recreate the shortcut file.
Note: The terms legacy and new console above refer to modes of the legacy conhost.exe-based console windows overall, as distinct from their modern successor, Windows Terminal.
Therefore, the remaining part of this answer is only of interest, if any of the following apply:
you're using the legacy console - either because you've opted to do so on Windows 10 or because you're running on Windows 8.1 or below - and want a simple command to fix the horizontal scrolling issue.
you want to modify the startup dimensions of your console window by way of shortcut files.
you're interested in a script that programmatically resizes a console window.
There's no simple UI fix to avoid the horizontal scrolling when you narrow a window using the mouse - short of using the window's system menu's Properties dialog to make the buffer width match the window with, but that's cumbersome.
Here is a command you can run after mouse-based resizing to fix the horizontal scrolling issue:
PowerShell:
[console]::BufferWidth = [console]::WindowWidth
So you don't have to type this every time, put it in a function, say, fixwin, and add it to your $PROFILE (initialization script):
function fixwin { [console]::BufferWidth = [console]::WindowWidth }
cmd.exe:
Using mode is not an option, because it would set your buffer height to the window height as well, so you'd lose your scroll-back buffer - see this answer.
You, can, however, call the above PowerShell command ad-hoc, using a DOSKEY macro:
doskey fixwin=powershell -noprofile -command "[console]::bufferwidth = [console]::windowwidth"
So you don't have to define the macro in every session, save the command to a batch file, say, .cmdrc.cmd in folder %USERPROFILE%, then modify the shortcut file that you use to start cmd.exe as follows:
Open the shortcut file's Properties dialog (via the shortcut menu, by right-clicking; for a taskbar item, right-click for the taskbar-related shortcut menu, then right-click the second to last item representing the underlying shortcut file).
In the Shortcut tab, replace the existing content of text box Target with the following:
%windir%\system32\cmd.exe /k "%USERPROFILE%\.cmdrc.cmd"
As an alternative to resizing a window after the fact, you can use a shortcut file to launch a console with preconfigured dimensions, which works with both the legacy and the new consoles:
Create a shortcut file pointing to the executable of interest (cmd.exe or powershell.exe).
Launch the shortcut.
Use the window's system menu's Properties dialog to set the desired window and buffer dimensions.
The next time you launch that shortcut file, the previously configured dimensions should take effect again.
To also remember the window position, position the window as desired, open the system menu's Properties dialog (again), uncheck Let system position window, and click OK.
cmd.exe / PowerShell script for fixing the buffer-width issue and/or programmatically resizing the window:
If you follow the instructions below, you'll be able to:
Simply execute rw (for resize window) after having used the mouse to narrow the window, so as to make the buffer width the same as the window width.
Alternatively, call rw <new-width> [<new-height>] to resize your window programmatically, which also sets the buffer width to the window width.
Instructions:
Pick or add a directory in your %PATH% in which to place the scripts below.
Create wrapper batch file rw.cmd with the following content:
#powershell.exe -executionpolicy unrestricted -noprofile -file "%~dpn0.ps1" %*
Create PowerShell script rw.ps1 with the following content (ignore the broken syntax-highlighting):
<#
.SYNOPSIS
Resizes the console window.
.DESCRIPTION
Resizes the current console window to the specified width (in columns)
and/or height (in lines.
Note that the window position doesn't change; i.e., the top-left corner of
the window remains in place, and the width / height expands or shrinks.
To only change the width, specify a single value; e.g.: 120
To only change the height, specify 0 for the width; e.g.: 0 60
Specify neither if you don't want to resize, but want to ensure that the
buffer width is set to the same value as the window width, so as to avoid
the need for horizontal scrolling.
This is convenient after having resized the window with the mouse.
Note that specifying values that are too large causes an error.
.PARAMETER Width
The new width (in columns) to resize the current console window to.
.PARAMETER Height
The new height (in lines) to resize the current console window to.
.PARAMETER KeepBufferWidth
By default, the buffer width is always set to the resulting window width,
so as to avoid the need for horizontal scrolling.
Use this switch if you want to keep the current buffer width.
.EXAMPLE
> rw 100 50
Makes the current console window 100 columns wide, and 50 lines tall.
> rw 100
Makes the current console window 100 columns, without changing the height.
> rw 0 70
Makes the current console window 70 lines tall, without changing the width.
> rw
Doesn't perform resizing, but ensures that the buffer width equals the
window width, so as to prevent horizontal scrolling.
#>
[cmdletbinding()]
param(
[uint16] $Width,
[uint16] $Height,
[switch] $KeepBufferWidth
)
if ($width) { [console]::WindowWidth = $width }
if ($height) { [console]::WindowHeight = $height }
# Unless asked not to, always set the buffer width to the window width to
# prevent horizontal scrolling.
if (-not $KeepBufferWidth) { [console]::BufferWidth = [console]::WindowWidth }

Scroll up in mongo console on Windows

I need to see output of db.currentOp() in my mongo console (mongo.exe) on Windows. But it gives so much results that they don't fit the screen. If I scroll up with the scrollbar on the left, I still can't get entire output. Is there a way to see the entire output?
Thanx
It sounds like you need to increase the Screen Buffer Size in your Windows Command Prompt settings.

Increase the VIM window size on Windows

Is there a command to increase the size of the Vim Command window on the window machine?
Note: I do not need to set the start up size in the vimrc.
I've no idea what is Vim "command window". GVim in Windows is usually one window, and one window only.
If you wish to change the size of that window, you can change the number of lines and columns
set lines=100
set columns=100
for example.
If you're reffering to the number of lines you have available for writing commands
set cmdheight=2 (two is usually enough)
Click on the VIM icon on the left top of the command window, select Properties, then Layout, and then change the Window Size for width and height
Or even better while in the editor use
:set lines=40
:set columns=80

Resources