Windows console width in environment variable
问题 How can I get the current width of the windows console in an environment variable within a batch file? 回答1: I like the approach using the built-in mode command in Windows. Try the following batch-file: @echo off for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W echo Console is %CONSOLE_WIDTH% characters wide Note that this will return the size of the console buffer, and not the size of the window (which is scrollable). If you wanted the