回复 1# locoman
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA- @echo off
- setlocal enabledelayedexpansion
- echo 正在获取硬件基础信息(需要几分钟时间)
- set "FileDX=%temp%\dxdiag.txt"
- dxdiag /whql:off /t "%FileDX%"
-
- echo 正在计算
- for /f "tokens=2 delims=\" %%i in ('wmic DesktopMonitor Get PNPDeviceID 2^>nul ^| findstr "DISPLAY"') do (
- set "MonitorPNP=%%i"
- )
-
- for /f "tokens=2*" %%i in ('findstr /c:"Monitor Name:" "%FileDX%"') do (
- set "MonitorName=%%i"
- )
-
- for /f "tokens=2*" %%i in ('findstr /c:"Monitor Model:" "%FileDX%"') do (
- set "MonitorModel=%%j"
- )
- if /i "!MonitorModel!" equ "Unknown" (
- for /f "tokens=2*" %%i in ('findstr /c:"Monitor Id:" "%FileDX%"') do (
- set "MonitorModel=%%j"
- )
- ) else if "!MonitorModel!" equ "" (
- set "MonitorModel=!MonitorPNP!"
- )
-
- for /f "tokens=3" %%i in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\!MonitorPNP!" /s ^| findstr "EDID"') do (
- set "MonitorEDID=%%i"
- )
- set "YearNum=!MonitorEDID:~34,2!"
- set "WeekNum=!MonitorEDID:~32,2!"
- set "HeightNum=!MonitorEDID:~42,2!"
- set "WidthNum=!MonitorEDID:~44,2!"
- set /a WeekNum=0x!WeekNum!*1
- set /a YearNum=0x!YearNum!*1+1990
- set /a HeightNum=0x!HeightNum!*1
- set /a WidthNum=0x!WidthNum!*1
- for /f %%i in ('powershell "[Math]::Round([Math]::Sqrt([Math]::Pow(!HeightNum!,2)+[Math]::Pow(!WidthNum!,2))*0.3937,1)"') do (
- set "MonitorSizeInch=%%i"
- )
-
- for /f "tokens=4" %%i in ('findstr /c:"User DPI Setting:" "%FileDX%"') do (
- set "MonitorDPI=%%i"
- )
-
- for /f "tokens=2*" %%i in ('findstr /c:"Native Mode:" "%FileDX%"') do (
- set "MonitorNative=%%j"
- )
-
- cls
- echo 名 称 : !MonitorName!
- echo 型 号 : !MonitorModel!
- echo 屏幕尺寸 : !HeightNum! X !WidthNum! 厘米 (!MonitorSizeInch! 英寸)
- echo 生产日期 : !YearNum!年第!WeekNum!周
- echo 像素密度 : !MonitorDPI! DPI
- echo 当前模式 : !MonitorNative!
- pause
复制代码
|