本帖最后由 pcl_test 于 2015-3-26 19:04 编辑
回复 9# cocn2002
先看看这样能不能获取- @echo off
- color 0a
- title 硬件检测
- mode con cols=40 lines=10
- sc config winmgmt start= auto >nul 2<&1
- net start winmgmt 2>nul
- setlocal ENABLEDELAYEDEXPANSION
- set "file=!COMPUTERNAME!.txt"
- set "txt=$info.tmp"
- if exist !file! del !file!
- cls
- echo.
- echo 正在收集硬件信息中,请稍候……
- echo --------------------------------
- echo ┏━━━━━━━━━━━━━━┓
- echo ┃ !!!请勿关闭本程序!!!┃
- echo ┃ 如果程序打扰了您的工作 ┃
- echo ┃ 请把程序最小化 ┃
- echo ┗━━━━━━━━━━━━━━┛
- echo --------------------------------
- ::从DXDIAG里获取主机型号、CPU、内存信息
- dxdiag /t !txt!
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /i /c:" System Model:"') do set XH=%%i
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /i /c:" Processor:"') do set CPU=%%i
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /c:" Memory:"') do set NC=%%i
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /c:"Available OS Memory:"') do set ANC=%%i
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /c:" Operating System:"') do set OS=%%i
- for /f "tokens=2 delims=:" %%i in ('type "!txt!" ^| findstr /c:" DirectX Version:"') do set DX=%%i
- ::内存容量取整
- set /a mmem=!NC:~0,-6!
- if !mmem! LEQ 1024 (
- set mem=!mmem!MB
- ) else (
- set /a mem=!mmem!*10/1024
- set mem=!mem:~,-1!.!mem:~-1!GB
- )
- set /a ammem=!ANC:~0,-6!
- if !ammem! LEQ 1024 (
- set amem=!ammem!MB
- ) else (
- set /a amem=!ammem!*10/1024
- set amem=!amem:~,-1!.!amem:~-1!GB
- )
- ::用WMIC命令获取硬盘型号与硬盘容量
- for /f "skip=1 tokens=*" %%i in ('wmic DISKDRIVE get caption') do (
- if not "%%i"=="" (set/a n+=1&set HDD!n!=%%i)
- )
- for /f "skip=1 delims=" %%i in ('wmic DISKDRIVE get size') do call set 硬盘大小=!!硬盘大小!! %%i
- for /f "tokens=1,2,3,4" %%i in ("!硬盘大小!") do call set Size1=%%i&set Size2=%%j&set Size3=%%k&set Size4=%%l
- ::硬盘容量取整
- set /a Size1=!Size1:~0,-9!
- set /a Size2=!Size2:~0,-9!
- set /a Size3=!Size3:~0,-9!
- set /a Size4=!Size4:~0,-9!
- if !Size1:~-1! LEQ 9 (
- if !Size1:~-1! GEQ 1 (
- set /a size1=!size1!+1
- )
- )
- if !Size2:~-1! LEQ 9 (
- if !Size2:~-1! GEQ 1 (
- set /a size2=!size2!+1
- )
- )
- if !Size3:~-1! LEQ 9 (
- if !Size3:~-1! GEQ 1 (
- set /a size3=!size3!+1
- )
- )
- if !Size4:~-1! LEQ 9 (
- if !Size4:~-1! GEQ 1 (
- set /a size4=!size4!+1
- )
- )
- if !Size1! GEQ 40 set /a size1=!size1!-!Size1:~-1!
- if !Size2! GEQ 40 set /a size2=!size2!-!Size2:~-1!
- if !Size3! GEQ 40 set /a size3=!size3!-!Size3:~-1!
- if !Size4! GEQ 40 set /a size4=!size4!-!Size4:~-1!
- if !Size2! LEQ 39 set /a size2=!size2!-1
- if !Size3! LEQ 39 set /a size3=!size3!-1
- if !Size4! LEQ 39 set /a size4=!size4!-1
- if !size1! GEQ 0 (set size1=!size1!G) else set "size1= "
- if !size2! GEQ 0 (set size2=!size2!G) else set "size2= "
- if !size3! GEQ 0 (set size3=!size3!G) else set "size3= "
- if !size4! GEQ 0 (set size4=!size4!G) else set "size4= "
- ::获取IP等信息及WMIC取显卡、声卡型号
- for /f "skip=1 delims=" %%i in ('wmic SOUNDDEV get ProductName ^|findstr .') do set SOUND=%%i
- for /f "tokens=1,2 delims==" %%a in ('wmic path Win32_VideoController get AdapterRAM^,Name /value^|findstr "AdapterRAM Name"') do set Video=%%b
- ::输出到文件并清除临时文件
- (echo.
- echo 当前用户: !USERNAME!
- echo 计算机名: !COMPUTERNAME!
- echo 系统相关: !OS!
- echo 主机型号: !XH!
- echo CPU 相关: !CPU!
- echo 内存总量: !mem!
- echo 可用内存: !amem!
- echo DirectX版本: !DX!
- if not "!HDD1!"=="" echo 硬盘1型号: !HDD1:~0,-2!
- if not "!HDD1!"=="" echo 硬盘1容量: !size1!
- if not "!HDD2!"=="" echo 硬盘2型号: !HDD2:~0,-2!
- if not "!HDD2!"=="" echo 硬盘2容量: !size2!
- if not "!HDD3!"=="" echo 硬盘3型号: !HDD3:~0,-2!
- if not "!HDD3!"=="" echo 硬盘3容量: !size3!
- if not "!HDD4!"=="" echo 硬盘4型号: !HDD4:~0,-2!
- if not "!HDD4!"=="" echo 硬盘4容量: !size4!
- echo 声卡型号: !SOUND!
- echo 显卡型号: !Video!
- echo.)>"!file!"
- exit
复制代码
|