Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to check console window width columns in bath script?  (Read 2906 times)

0 Members and 1 Guest are viewing this topic.

PiotrMP006

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    How to check console window width columns in bath script?
    « on: April 02, 2019, 02:17:01 AM »
    Hi

    How to check console window width columns in bath script?

    Salmon Trout

    • Guest
    Re: How to check console window width columns in bath script?
    « Reply #1 on: April 02, 2019, 11:58:01 AM »
    Parse output of mode con command using FOR /F. Note: must escape pipe symbol | with caret ^.

    @echo off
    for /f "tokens=1-2" %%A in ('mode con ^| find "Columns"') do set colwide=%%B
    echo This console is %colwide% columns wide.
    pause


    Output of batch:

    C:\>colwidth.bat
    This console is 104  columns wide.
    Press any key to continue . . .


    Complete output of mode con

    C:\>mode con

    Status for device CON:
    ----------------------
        Lines:          9001
        Columns:        104
        Keyboard rate:  31
        Keyboard delay: 1
        Code page:      850



    Note: Height is height of buffer, not height of window.