Jan 27, 2012

Function: SetWindowHeight

SetWindowHeight receives signed or unsigned integers. Changes made by it are global and permanent, unlike those that can be made using the MODE command.

@echo off
for %%A in ( higherbits lowerbits ) do if defined %%A set %%A=
set myself=%~n0
title Type 'reset' to restore default
set ch=
set/p ch=úIncrease window height by   
call:SetWindowHeight %ch%&&goto RestartMyself
goto loop
if "%1"=="reset" (
 goto RestartMyself
::title Setting appropriate window height ...
reg query "HKCU\Console"|find "system32">nul 2>&1||goto loaddefault
for /f %%A in ('reg query "HKCU\Console"^|find "system32"') do reg query "%%A" /v "WindowSize">nul 2>&1||goto loaddefault
for /f %%A in ('reg query "HKCU\Console"^|find "system32"') do reg query "%%A" /v "WindowSize">file.tmp
for /f "tokens=3" %%A in ('type file.tmp^|find "WindowSize"') do (
 set tempval=%%A
del file.tmp
set wHeight=%tempval:~0,-4%
set tempval=
set/a wHeight*=1
::set/a wHeight=( %wHeight% - ( %wHeight% - %1 ))
set/a wHeight=( %wHeight% + (%1))
if %wHeight% LEQ 0 (
 set higherbits=19
 goto loaddefault
reg add "HKCU" /v "remove_me" /t "REG_DWORD" /d "%wHeight%" /f>nul 2>&1
for /f "tokens=3" %%G in ('reg query "HKCU" /v "remove_me"') do (
 set higherbits=%%G
reg delete "HKCU" /v "remove_me" /f>nul 2>&1
for /f "tokens=3" %%G in ('reg query "HKCU\Console" /v "WindowSize"') do (
 set tempval=%%G
if not defined higherbits (
 set wHeight=%tempval:~0,-4%
 goto increase_height
set lowerbits=%tempval:~-4%
if "%higherbits:~0,2%"=="0x" (
 set higherbits=%higherbits:~2%
set tempval=
set regfile=%RANDOM%.reg
echo Windows Registry Editor Version 5.00>%regfile%
echo [HKEY_CURRENT_USER\Console\%%SystemRoot%%_system32_cmd.exe]>>%regfile%
echo "WindowSize"=dword:%higherbits%%lowerbits%>>%regfile%
reg import %regfile%>nul 2>&1&&del %regfile%
if exist %regfile% (
 del %regfile%
for /f %%A in ('reg query "HKCU\Console"^|find "system32"') do reg delete "%%A" /v "WindowSize" /f>nul 2>&1
::start cmd /k "@echo off&ping -n 2>nul 2>&1&start %myself%.cmd /WindowSizeSet&exit"
start cmd /k "@echo off&ping -n 2>nul 2>&1&start %myself%.cmd&exit"

No comments:

Post a Comment