Change Batch File Font

There is a way to change the font size in cmd (batch file): Change the value of the keys in "HKCU\Console".

I create a batch file to help those who need it(copy the code below and insert your code in,then save the file as a .bat file)

@echo off

set /a fontSize=32

:: unset %SystemRoot% as the variate affect the execution of 'reg delete'  in command line

set SystemRootA=%System

set SystemRootB=Root%

set SystemRoot=%SystemRootA%%SystemRootB%

title Font Settings by TYAI 2022.6.20

reg query "HKCU\Console"|find /i "FaceName"&&cls&&goto :found_Font_settings||cls&&goto :change_Font_settings

goto :eof

:found_Font_settings

::######################################

::put your code in this section

::######################################

title Font Settings

mode con cols=30 lines=5

echo Hello, World!

ping 127.0.0.1 >nul

:: clear font settings before exit

goto :clear_Font_settings

exit 0

:change_Font_settings

::set /p fontSize=Enter the size[default:%fontSize%]:

::reg add "HKCU\Console" /v "CodePage" /t REG_DWORD /d "0x000003a8" /f >nul

reg add "HKCU\Console" /v "FontSize" /t REG_DWORD /d "0x00%fontSize%0000" /f >nul

reg add "HKCU\Console" /v "FontWeight" /t REG_DWORD /d "0x00000190" /f >nul

reg add "HKCU\Console" /v "FaceName" /t REG_SZ /d "新宋体" /f >nul

::reg add "HKCU\Console" /v "FontFamily" /t REG_DWORD /d "0x00000036" /f >nul

start "" "%0"

exit 0

:clear_Font_settings

reg delete "HKCU\Console" /v "CodePage" /f 1>nul 2>nul

reg delete "HKCU\Console" /v "FontSize" /f 1>nul 2>nul

reg delete "HKCU\Console" /v "FontWeight" /f 1>nul 2>nul

reg delete "HKCU\Console" /v "FaceName" /f 1>nul 2>nul

reg delete "HKCU\Console" /v "FontFamily" /f 1>nul 2>nul

exit 0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值