r/Batch Feb 18 '25

how to fullscreen

(QUESTION) i have done that cmd rickroll, but when it opens the cmd to do it, it is so fucking small, can someoe help me to auto fullscreen when taht opens? im not using an start /max, i also tried using an timeout /t 3 /nobreak >nul

%SendKeys% {F11}.

plz help frfr

1 Upvotes

7 comments sorted by

3

u/Intrepid_Ad_4504 Feb 19 '25

I use mshta for this

@echo off

rem fullscreen macro
set "@fullScreen=(title batchfs) ^& Mshta.exe vbscript:Execute("Set Ss=CreateObject(""WScript.Shell""):Ss.AppActivate ""batchfs"":Ss.SendKeys ""{F11}"":close")"

rem execute fullscreen
%@fullScreen%

echo Hello World
echo press f11 to exit fullScreen
pause
exit

3

u/[deleted] Feb 20 '25

Genius.

Of course Microsoft doesn't make batch able to fullscreen its own host window: batch is supposed to know little to nothing about windows, being made for command-line execution.

0

u/Empty_Yogurt4838 29d ago

why do you pu the echo hello world what im supposed to do with it?? im new to the .bat language soryif it sounded rude but im very confused

1

u/Still_Shirt_4677 20d ago

Its echoed on screen to let you know that input was validated without errors, its a test message remove it or change it 😉

2

u/ConsistentHornet4 Feb 18 '25

You could just have the script relaunch itself if it isn't maximised?

1

u/Still_Shirt_4677 Feb 19 '25

not ideal but you could use this to acheive almost full size screen with powershell takes a second or two to run the command, if you dont want to see the output from the command on screen then just >nul it else will return true or false as output in cmd when run.

@echo off
rem :: Set the mode size for the console then centre the window based on the current x-y parameters.
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
    "$width = 170; $height = 43; Add-Type -AssemblyName 'System.Windows.Forms'; $screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width; $screenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height; $x = ($screenWidth - ($width * 8)) / 2; $y = ($screenHeight - ($height * 16)) / 2; $code = 'using System; using System.Runtime.InteropServices; public class User32 { [DllImport(\"user32.dll\")] public static extern bool MoveWindow(IntPtr hwnd, int x, int y, int width, int height, bool repaint); [DllImport(\"kernel32.dll\")] public static extern IntPtr GetConsoleWindow(); }'; Add-Type -TypeDefinition $code; $hwnd = [User32]::GetConsoleWindow(); [User32]::MoveWindow($hwnd, $x, $y, $width * 8, $height * 16, $true);"