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
Related
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 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 }
I have a Windows 7 laptop with the size of text and apps set to small. However, one program I use needs this setting to be set on medium. I'm sick of changing this setting every time I have to use the program.
How do I use a batch file to change the size and text of this program to medium without impacting other programs and keep the resolution at 1280x960?
I have no previous experience in writing batch files.
If the program is a batch file or its cmd.exe, you can just create a shortcut to that program, go into shortcut properties, go into the Layout tab and set the window size by changing Width to the width you want the window to be and the Height to the height you want to window to be. For the text go into the Font tab and set the text size to an option already there or input a custom one by clicking in the box that tells you the size selected and type in your own. Then press enter. This will close the properties. You must do this or it will go to the nearest option to your custom size. Now simply run the shortcut instead of running said program and it should have custom size and text.
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
I am on windows xp,
Is there any way to maximize my cmd.exe window?
I am doing some mysql and it is so difficult to read results of my queries in such a small window.
Why maximize does not really maximizes it?
Is there a way for maximizing?
Or maybe an alternative command prompt I can use?
thanks
Click on the top left icon in the window (the "C:\" one) and select "Properties".
Then select the "Layout" tab and change the window size to what you want it to be (I have 128x50 for the screen and 128x999 for the scroll buffer). You can also optionally set the top left position (I always have it at 1,1) if you don't want Windows itself deciding where the window goes.
When you click on OK, make sure you tell it to modify the shortcut that started the window.
Then it will remember.
This is for XP, other MS operating systems may vary slightly but the general idea should be the same.
Try this:
In the Command window, right click the Title
bar and select Properties from the
popup menu. The property sheet
appears.
In the property sheet, select 'Full
Screen' in the 'Display Options'
box.
Close the property sheet by clicking
OK and select 'Save proeprties for
future windows with same title'.
I would recommand that you use powershell
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx
It also support full screen mode, and some other nice feature.
Command Window Default Properties
Click on the sytem menu, or with focus set on the Command Windows, press Alt+Space, and select Properties. Change your Font, Window Size, and so on. I always change my Window Size (on the Layout tab) to Width 80 by Height 65 and Screen Buffer Size to 80 by 300.
Check out Console2, it seems to be about the most promising window enhancement for cmd.exe.
I have to say, cmd.exe is probably the worst part of windows! Especially the copy pasting support, etc.
Personally, I use putty to ssh into a Linux box when I really need to do command line work, you can't go past Bash.
Even though you could install that on windows using Cygwin, which will allow you to use another console, although this doesn't have the ability to override the windows cmd.exe, it might be worth a shot given that you are trying to use a command line application, and not windows :).
Access Properties by right clicking on top of the CMD window, go back to the Font tab, select either 10 x 18 or 12 x 16, and then click OK. You'll then need to go back to the Layout tab and reset the Screen Buffer Size Width to the appropriate value. For example, I selected the 10 x 18 font size and then changed the Screen Buffer Size Width to 160X300 and window size width to 134X37.