windows - 获取屏幕分辨率作为cmd中的变量

标签 windows batch-file cmd resolution

我需要一个脚本来根据所使用的屏幕分辨率复制特定图像。 到目前为止,我发现 wmic desktopmonitor get screenheight 为我提供了适当的输出,但我无法将其解析为可用变量 问题是输出在三行上,我只需要第二行的信息。

有人能帮忙吗?

最佳答案

@Stephan's answer修改为与所有 Windows 版本(包括 Windows 8)兼容:

setlocal
for /f %%i in ('wmic path Win32_VideoController get CurrentHorizontalResolution^,CurrentVerticalResolution /value ^| find "="') do set "%%i"
echo your screen is %CurrentHorizontalResolution% * %CurrentVerticalResolution% pixels

关于windows - 获取屏幕分辨率作为cmd中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25532444/

相关文章:

c++ - 有什么方法可以通过 Windows 上的代码创建动态磁盘吗?

windows - IsFile、IsDirectory 测试窗口

sorting - 在批处理文件中按文件类型将文件 move 到不同目录(Win)

windows - 错误 : Flutter plugin not installed; this adds Flutter specific functionality

batch-file - 如何使用 WinSCP 下载较新的文件并将其保存到两个本地文件夹?

java - 从java执行命令提示符命令来创建jar文件

c# - Windows 中的等效任务集

python - Windows 上线程和 PyGTK 的执行顺序

.net - 为 mac 编写 .net 软件

windows - .bat 文件中的 Sed 等价物