若仅是用批处显示当前屏幕宽高度,可改用系统内置的wmic.exe或powershell方法(代码如下)
批处调用 ‘没有网页窗口内交互操作的mshta代码’ 总会造成闪屏不适感,若楼主对此无所谓就另当别论了...
一。wmic方法- @echo off &for /f "tokens=1-2 delims= " %%1 in (
- 'wmic path Win32_VideoController get CurrentHorizontalResolution^,CurrentVerticalResolution'
- ) do (set/a "w=%%1,h=%%2" 2>nul)
- echo,当前水平分辨率=%w% 当前垂直分辨率=%h%
- pause&exit/b
复制代码
二。powershell方法- @echo off &for /f "delims=" %%a in (
- ' powershell "Get-WmiObject win32_videocontroller"^|findstr /irc:"CurrentHorizontalResolution.*[0-9]" /irc:"CurrentVerticalResolution.*[0-9]" '
- ) do echo,%%a
- pause&exit/b
复制代码