batch-file – BATCH – 从Windows命令行获取显示分辨率并设置变
发布时间:2020-12-14 01:35:23 所属栏目:Windows 来源:网络整理
导读:@echo offset h=wmic desktopmonitor,get screenheightset w=wmic desktopmonitor,get screenwidthecho %h%echo %w%pause 而不是得到 – 1600 2560 我明白了 – echo wmic desktopmonitor,获取screenwidth echo wmic desktopmonitor,获取屏幕高度 我希望这个
@echo off set h=wmic desktopmonitor,get screenheight set w=wmic desktopmonitor,get screenwidth echo %h% echo %w% pause 而不是得到 – 1600 我明白了 – echo wmic desktopmonitor,获取screenwidth echo wmic desktopmonitor,获取屏幕高度 我希望这个批处理脚本能够获得我的显示分辨率大小并将其设置为高度和宽度变量,并且能够回显数量. 解决方法
使用desktopmonitor,您只能获得dpi.对于像素分辨率,您需要Win32_VideoController:
@echo off for /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do ( set "%%#">nul ) echo %CurrentHorizontalResolution% echo %CurrentVerticalResolution% 如果你想我也可以添加一个dpi分辨率吸气剂? 另一种允许你获得更多监视器分辨率的方法是使用DxDiag(虽然它会创建一个临时文件并且会更慢): 随着dxdiag: @echo off del ~.txt /q /f >nul 2>nul start "" /w dxdiag /t ~ setlocal enableDelayedExpansion set currmon=1 for /f "tokens=2 delims=:" %%a in ('find "Current Mode:" ~.txt') do ( echo Monitor !currmon! : %%a set /a currmon=currmon+1 ) endlocal del ~.txt /q /f >nul 2>nul 这将打印所有显示器的分辨率. 编辑: 一个wmic脚本,它将检测Windows的版本,并在需要时使用不同的wmi类: @echo off setlocal for /f "tokens=4,5 delims=. " %%a in ('ver') do set "version=%%a%%b" if version lss 62 ( ::set "wmic_query=wmic desktopmonitor get screenheight,screenwidth /format:value" for /f "tokens=* delims=" %%@ in ('wmic desktopmonitor get screenwidth /format:value') do ( for /f "tokens=2 delims==" %%# in ("%%@") do set "x=%%#" ) for /f "tokens=* delims=" %%@ in ('wmic desktopmonitor get screenheight /format:value') do ( for /f "tokens=2 delims==" %%# in ("%%@") do set "y=%%#" ) ) else ( ::wmic path Win32_VideoController get VideoModeDescription,CurrentVerticalResolution,CurrentHorizontalResolution /format:value for /f "tokens=* delims=" %%@ in ('wmic path Win32_VideoController get CurrentHorizontalResolution /format:value') do ( for /f "tokens=2 delims==" %%# in ("%%@") do set "x=%%#" ) for /f "tokens=* delims=" %%@ in ('wmic path Win32_VideoController get CurrentVerticalResolution /format:value') do ( for /f "tokens=2 delims==" %%# in ("%%@") do set "y=%%#" ) ) echo Resolution %x%x%y% endlocal (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Windows Server 2008中的Set-NetFirewallRule替代
- 自动部署Windows服务 – 工具
- windows-server-2008 – 具有高磁盘时间百分比的
- 搭配 VS Code Remote 远程开发扩展在 WSL 下开发
- julia-lang – 为什么typeof十六进制或二进制数U
- 使用Microsoft Access作为MySQL数据库的前端?
- windows-phone-7 – Silverlight TextBlock可以容
- windows – 如何在启动时同步计算机的时钟?
- windows安装RabbitMQ注意事项
- 在Windows 7中完全自动安装虚拟机工具
热点阅读