TechKnow

Author Topic: [BAT] QCMD (Full Screen Quadro Command Prompts)  (Read 192 times)

0 Members and 1 Guest are viewing this topic.

Offline HcH

  • TechKnow Owner, Ethical Hacker
  • Administrator
  • Uber Member
  • *****
  • Posts: 9867
  • Karma: +2282/-107
[BAT] QCMD (Full Screen Quadro Command Prompts)
« on: March 30, 2018, 08:12:22 PM »
Good day everyone!

This is a script I wrote in 2014, which does quite a lot in order to start 4 command prompts in full screen mode.

It's tested on Windows7, let me know if it works with other versions in the comments below!




@echo off
@title QUADRA-COMMAND
REM Reset command prompt window position in the registry
reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x00000000 /f
REM Jump to the dec2hex converter
if not "%1" == "" goto :DEC2HEX
REM This command sets the %0 parameter(full location and filename of this BAT file) to just the filename and extension, which we're going to use later on to call this script with other parameters for decimal conversion)
set SELF=%~nx0
cls

echo Q-CMD v0.1a:

echo.
echo Getting screen resolution ...
for /f "skip=1" %%a in ('wmic desktopmonitor get screenwidth') do if %%a GTR 100 set RESX=%%a
for /f "skip=1" %%a in ('wmic desktopmonitor get screenheight') do if %%a GTR 100 set RESY=%%a
echo Resolution found: %RESX%x%RESY%

echo.
REM We want 2 screens horizontally ? the we divide with 2 ! Higher values would also work
echo Dividing resolution with two ...
set /a RESXD=%RESX%^/2
set /a RESYD=%RESY%^/2
echo Divided values: %RESXD% ^/ %RESYD%

echo.
REM OK, here it's tricky, I found out how much each character and borders are in pixelsize
echo Calculating Quadra Command Prompt Sizes ...
set /a RESXE=%RESXD%^/8
set /a RESXE=%RESXE%^-2
set /a RESYE=%RESYD%^/13
echo Optimal Quadra values: %RESXE% ^/ %RESYE%

echo.
REM In order to use the calculated values we'll call this script with parameters that runs a decimals to hexadecimals conversion)
echo Converting decimals to hexadecimals ...
for /f %%a in ('%SELF% %RESXD%') do set RESXHEX=%%a
for /f %%a in ('%SELF% %RESYD%') do set RESYHEX=%%a
echo Converted values: %RESXHEX% x %RESYHEX%

REM set RESYHEX=%RESYD%
REM set RESXHEX=%RESXD%

echo.
REM When the output value is prefixed with a zero, it doesn't output the zero, but we need that 'one' (lol) so we perform a dirty fix to find out if the value has 4 characters, and if not, just assume the zero fell off and attach it to the eventual used registry values for positioning
echo Validating and correcting the converted values ...
:VALVAL
SET string=%RESXHEX%
:VALVALa
SET temp_str=%string%
SET str_len=0
:loopA
if defined temp_str (
    SET temp_str=%temp_str:~1%
    SET /A str_len+=1
    GOTO loopA
)
echo %string% is %str_len% characters.
if %str_len% LSS 4 set string=0%string%&&GOTO :VALVALa
if %str_len% GTR 4 GOTO :VALVAL2
set RESXHEXC=%string%

:VALVAL2
SET string=%RESYHEX%
:VALVAL2a
SET temp_str=%string%
SET str_len=0
:loopB
if defined temp_str (
    SET temp_str=%temp_str:~1%
    SET /A str_len+=1
    GOTO loopB
)
echo %string% is %str_len% characters.
if %str_len% LSS 4 set string=0%string%&&GOTO :VALVAL2a
if %str_len% GTR 4 GOTO :VALVALEND
set RESYHEXC=%string%
echo Validation complete, useable position values are %RESXHEXC% x %RESYHEXC%

:VALVALEND
echo.
echo Hit any key to launch QUADRA-CMD^!
pause>NUL

REM This is going to speak pretty much for itself, it will write a new cmd windows position to the registry and launches a new instance, then performs it for the other calculated values.
reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x00000000 /f
echo start "CMD#1" "cmd /k" mode %RESXE%,%RESYE%"
start "CMD#1" "cmd /k" mode %RESXE%,%RESYE%"
waitfor /T 1 God

reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x0000%RESXHEXC% /f
echo start "CMD#2" "cmd /k" mode %RESXE%,%RESYE%"
start "CMD#2" "cmd /k" mode %RESXE%,%RESYE%"
waitfor /T 1 God

reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x%RESYHEXC%0000 /f
echo start "CMD#3" "cmd /k" mode %RESXE%,%RESYE%"
start "CMD#3" "cmd /k" mode %RESXE%,%RESYE%"
waitfor /T 1 God

reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x%RESYHEXC%%RESXHEXC% /f
echo start "CMD#4" "cmd /k" mode %RESXE%,%RESYE%"
start "CMD#4" "cmd /k" mode %RESXE%,%RESYE%"
waitfor /T 1 God

reg add hkcu\console /t REG_DWORD /v WindowPosition /d 0x00000000 /f

goto :END

REM Here's a nice one, a small trick to convert decimals to hexadecimals, can be called externally but basically also internally with perhaps some modification
:DEC2HEX
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A Num = %~1
SET Hex=
SET Hex.10=A
SET Hex.11=B
SET Hex.12=C
SET Hex.13=D
SET Hex.14=E
SET Hex.15=F
:DEC2HEXL
SET /A "HexTmp = Num %% 16"
IF %HexTmp% GTR 9 SET HexTmp=!Hex.%HexTmp%!
SET /A Num /= 16
SET Hex=%HexTmp%%Hex%
IF %Num% GTR 0 GOTO :DEC2HEXL
ECHO.%HEX%
ENDLOCAL

:END
« Last Edit: March 30, 2018, 09:04:31 PM by Stephan »