How to change Screen buffer size in Windows Command Prompt from batch script

后端 未结 14 1497
清歌不尽
清歌不尽 2020-12-02 09:59

I know you can do right click properties ->layout and there change it manually.

But how would you go about changing it from a Windows batch script?

I know yo

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 10:15

    mode con lines=32766
    

    sets the buffer, but also increases the window height to full screen, which is ugly.

    You can change the settings directly in the registry :

    :: escape the environment variable in the key name
    set mySysRoot=%%SystemRoot%%
    
    :: 655294544 equals 9999 lines in the GUI
    reg.exe add "HKCU\Console\%mySysRoot%_system32_cmd.exe" /v ScreenBufferSize /t REG_DWORD /d 655294544 /f
    
    :: We also need to change the Window Height, 3276880 = 50 lines
    reg.exe add "HKCU\Console\%mySysRoot%_system32_cmd.exe" /v WindowSize /t REG_DWORD /d 3276880 /f
    

    The next cmd.exe you start has the increase buffer.

    So this doesn't work for the cmd.exe you are already in, but just use this in a pre-batch.cmd which than calls your main script.

提交回复
热议问题