执行批处理文件时,指定的命令提示符的大小 [英] Specify the size of command prompt when executing a batch file

查看:192
本文介绍了执行批处理文件时,指定的命令提示符的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:如何指定命令提示的字体和窗口的大小?我使用的是Windows 7专业版。 确定。对不起,我试图用一个命令来完成上面的东西,所以我不接受那些preSS-中的属性的答案。

How do I specify the font of command prompt and the size of the window? I'm using Windows 7 Professional. OK. I'm sorry, I'm trying to use a command to do the above things, so I'm not accepting those "press-the-properties" answer.

推荐答案

如果你想以编程方式更改控制台字体大小,看的此页面和的此页面。基本上,你必须从TechNet页面的该模块的源copypaste到 SetConsoleFont.psm1 在本地计算机上称为一个新的文件。把它放到一个同名的文件夹没有EXT(因此它成为 SetConsoleFont \\ SetConsoleFont.psm1 )。在命令行中,的powershell -command回声$ ENV:PSModulePath看到这里,你应该把那个 SetConsoleFont \\ 文件夹(可能在%USERPROFILE%\\文档\\ WindowsPowerShell \\模块)。

If you want to change the console font size programmatically, see this page and this page. You basically have to copypaste that module source from the technet page into a new file called SetConsoleFont.psm1 on your local machine. Put it into a folder of the same name without ext (so it becomes SetConsoleFont\SetConsoleFont.psm1). From the command line, powershell -command "echo $env:PSModulePath" to see where you should put that SetConsoleFont\ folder (probably in %userprofile%\Documents\WindowsPowerShell\Modules).

如果你希望在你的批处理脚本内的TechNet脚本,让你的批处理脚本创建 [module_path_dir] \\ SetConsoleFont \\ SetConsoleFont.psm1 在用户的机器上,我建议一个批处理脚本定界符将是一个简单的方法,包括它和它动态写入。

If you want to include that technet script within your batch script and have your batch script create [module_path_dir]\SetConsoleFont\SetConsoleFont.psm1 on the user's machine, I suggest a batch script heredoc would be an easy way to include it and write it dynamically.

在你的模块路径模块,现在可以用它从CMD线。

With the module in your module path, you can now use it from the cmd line.

的powershell -command&放大器; {设置executionpolicy下RemoteSigned;导入模块SetConsoleFont;获取-ConsoleFontInfo |格式表-AutoSize}

会告诉你提供给您的控制台字体大小的表。从其中选择一个 nFont 列,并激活它是这样的:

will show you a table of the font sizes available to your console. Choose one from the nFont column and activate it like this:

的powershell -command&放大器; {设置executionpolicy下RemoteSigned;导入模块SetConsoleFont;设置-CONSOLEFONT 6}

如果你想要做的是调整控制台窗口和缓冲区,这要简单得多。不需要的模块或进口或执行策略压倒一切。 模式骗子:COLS = N1线= N 将更改窗口尺寸,并有一个PowerShell单行改变缓冲(回溯历史)尺寸

If all you want to do is resize the console window and buffer, that's much simpler. No modules or importing or execution policy overriding is needed. mode con: cols=n1 lines=n2 will change the window dimensions, and there's a PowerShell one-liner for changing the buffer (scrollback history) size.

:: Resize the console window and increase the buffer to 10000 lines
call :consize 80 33 80 10000

:: put the main part of your bat script here.
:: script
:: script
:: script
:: etc.

goto :EOF

:consize <columns> <lines> <buffercolumns> <bufferlines>
:: change console window dimensions and buffer
mode con: cols=%1 lines=%2
powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%3;$B.height=%4;$W.buffersize=$B;}"
goto :EOF

这篇关于执行批处理文件时,指定的命令提示符的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆