纯批处理获取硬件信息的代码

纯批处理获取硬件信息的代码,第1张

先声明:我私下会不断的更新代码,只有大幅度更新才会上传到这里(目前核心代码基本完善)!

兼容XP Win7 Win8 win10

本程序特性:

1.运行环境判断,若自身被修改则自动闪退;若PE环境则提示并指引退出;若虚拟机环境则提示信息获取可能不准;若非管理员权限也会截取并提示。
2.关于硬盘、内存容量的计算方面支持 字节 KB MB GB TB PB
3.由于有些电脑多网卡、显卡、声卡,此程序只获取正在使用的相关信息
4.硬盘温度,使用时间,通电次数纯批处理实现!(原创代码,转载请注明出处!)
5.纯批处理实现系统密匙获取(通过注册表中的加密数据进行解密)
以下是最新版本,不用后翻。

更新内容:

1.解决了众多网友反应的关于网卡信息获取不准的问题,目前已基本完美
2.调整了代码结构,优化了效率和逻辑顺序(基本上等于重写了一遍)
3.解决了之前多种情况遇到的闪退,现在只要不改代码基本是不会闪退的
最后声明:电脑系统情况多样且复杂并非完美版本 ,希望大家多多测试并提供BUG截图 以后会根据大家的测试结果不断更新。
本人QQ:540044977 若要获取实时最新版可以加好友索要,欢迎志同道合的朋友前来交流。

以下是代码:

@echo off
mode con cols=82 lines=25
Setlocal EnableDelayedExpansion
call :Inspect
title 获取硬件信息 - 正在获取相关信息,请稍等...
echo !Tit!
echo .............................................................
echo.
DxDiag /t %Temp%\Dxdiag.dll
Ping www.baidu.com>nul
if %errorlevel%==0 set NetWorking=已联网
if %errorlevel%==1 set NetWorking=未联网
:DxDiag
if exist "%Temp%\Dxdiag.dll" (
	for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Operating System: " %Temp%\Dxdiag.dll') do (
		for /f "delims=(" %%j in ("%%i") do set OS=%%j
	)
	) else (
	Goto :DxDiag
)
title 获取硬件信息 - %OS%
for /f "tokens=2 delims=:" %%i in ('Findstr /IC:"Processor: " %Temp%\Dxdiag.dll') do set CPU=%%i
for /l %%i in (256 -1 0) do if "!CPU:~%%i,1!"=="" set CPU.Len=%%i
if %CPU.Len% gtr 67 set CPU= %CPU:~0,60% ...
echo.CPU .......%CPU%
echo.
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic BaseBoard get Manufacturer^,Product^,SerialNumber^,Version /value 2^>nul') do (
	set /a Row =1
	if !Row! == 1 set Manufacturer=%%i
	if !Row! == 2 set Product=%%i
	if !Row! == 3 set SerialNumber=%%i
	if !Row! == 4 set Version=%%i
)
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic bios get InstallableLanguages^,ReleaseDate^,SMBIOSBIOSVersion /value 2^>nul') do (
	set /a Row =1
	if !Row! == 1 set InstallableLanguages=%%i
	if !Row! == 2 set ReleaseDate=%%i
	if !Row! == 3 set SMBIOSBIOSVersion=%%i
)
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Memphysical Get MaxCapacity^,MemoryDevices /Value 2^>nul') do (
	set /a Row =1
	if !Row! == 1 set MaxCapacity=%%i
	if !Row! == 2 set MemoryDevices=%%i
)
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Csproduct get Uuid /Value 2^>nul') do set Uuid=%%i
if "%Version%"==" " set Version=无
if "%SerialNumber%"==" " set SerialNumber=无
set /a MaxCapacity=!MaxCapacity!/1048576
set MaxCapacity=!MaxCapacity! GB
set MemoryDevices=!MemoryDevices! 个
set InstallableLanguages=!InstallableLanguages! 国语言
set ReleaseDate=%ReleaseDate:~0,4% 年 %ReleaseDate:~4,2% 月 %ReleaseDate:~6,2% 日
if "%Uuid%" == "00000000-0000-0000-0000-000000000000" set Uuid=主板维修过
if /i "%Manufacturer:~0,3%" == "MSI"    set Manufacturer=微星
if /i "%Manufacturer:~0,4%" == "ASUS"    set Manufacturer=华硕
if /i "%Manufacturer:~0,4%" == "TIMI"    set Manufacturer=小米
if /i "%Manufacturer:~0,4%" == "SOYO"    set Manufacturer=梅捷
if /i "%Manufacturer:~0,4%" == "ONDA"    set Manufacturer=昂达
if /i "%Manufacturer:~0,5%" == "SUPOX"   set Manufacturer=磐正
if /i "%Manufacturer:~0,5%" == "PCASL"   set Manufacturer=翔升
if /i "%Manufacturer:~0,5%" == "INTEL"   set Manufacturer=英特尔
if /i "%Manufacturer:~0,6%" == "MAXSUN"   set Manufacturer=铭瑄
if /i "%Manufacturer:~0,6%" == "LENOVO"   set Manufacturer=联想
if /i "%Manufacturer:~0,6%" == "ASROCK"   set Manufacturer=华擎
if /i "%Manufacturer:~0,6%" == "GALAXY"   set Manufacturer=影驰
if /i "%Manufacturer:~0,7%" == "TOSHIBA"  set Manufacturer=东芝
if /i "%Manufacturer:~0,7%" == "BIOSTAR"  set Manufacturer=映泰
if /i "%Manufacturer:~0,8%" == "GIGABYTE"  set Manufacturer=技嘉
if /i "%Manufacturer:~0,8%" == "COLORFUL"  set Manufacturer=七彩虹
if /i "%Manufacturer:~0,8%" == "SAPPHIRE"  set Manufacturer=蓝宝石
if /i "%Manufacturer:~0,8%" == "MECHREVO"  set Manufacturer=机械格命
if /i "%Manufacturer:~0,10%" == "SUPERMICRO" set Manufacturer=超微
echo.主板 ....... %Manufacturer%  %Product%
echo.
for /f "tokens=2 delims==" %%i in ('Wmic Path Win32_PhysicalMemory Get BankLabel /value 2^>nul') do set /a MemoryQuantity =1
set MemorySize=0
for /f "tokens=3 delims=:" %%i in ('Find /c /v "" %0') do set /a H.Size=%%i
for /f "tokens=2 delims==" %%i in ('Wmic Path Win32_PhysicalMemory Get Capacity /value 2^>nul') do (
	set Capacity=%%i
	call :Addition !Capacity! !MemorySize! MemorySize
)
call :GetSize !MemorySize! MemorySize
if not !H.Size!==1069 Goto :Eof
if "!MemorySize:~-5,3!"==".00" set MemorySize=!MemorySize:~0,-5! !MemorySize:~-2!
if "!MemorySize!"=="EB" Goto :Eof
echo.内存 ....... %MemoryQuantity% 条  %MemorySize%
echo.
for /f "tokens=2 delims==" %%i in ('Wmic DiskDrive Get Model /Value^|Find /i /v "USB"') do (
	set /a HdQuantity =1
	if !HdQuantity! == 1 set FirstDisk=%%i
)
echo.硬盘 ....... %HdQuantity% 块  %FirstDisk% (主)
echo.
set Row=0
for /f "skip=2 tokens=2 delims==" %%i in ('Wmic Path Win32_VideoController Get Name^,AdapterRam^,DriverDate^,DriverVersion^,VideoProcessor^,MaxRefreshRate^,MinRefreshRate^,VideoProcessor^,CurrentBitsPerPixel^,CurrentRefreshRate^,CurrentHorizontalResolution^,CurrentVerticalResolution /Value 2^>nul') do (
	set /a Row =1
	if !Row! == 1 set AdapterRAM=%%i
	if !Row! == 2 set CurrentBitsPerPixel=%%i
	if !Row! == 3 set CurrentHorizontalResolution=%%i
	if !Row! == 4 set CurrentRefreshRate=%%i
	if !Row! == 5 set CurrentVerticalResolution=%%i
	if !Row! == 6 set DriverDate=%%i
	if !Row! == 7 set DriverVersion=%%i
	if !Row! == 8 set MaxRefreshRate=%%i
	if !Row! == 9 set MinRefreshRate=%%i
	if !Row! == 10 set VideoName=%%i
	if !Row! == 11 set VideoProcessor=%%i
)
if "%CurrentBitsPerPixel%" == "" (
	set Row=0
	for /f "skip=15 tokens=2 delims==" %%i in ('Wmic Path Win32_VideoController Get Name^,AdapterRam^,DriverDate^,DriverVersion^,VideoProcessor^,MaxRefreshRate^,MinRefreshRate^,VideoProcessor^,CurrentBitsPerPixel^,CurrentRefreshRate^,CurrentHorizontalResolution^,CurrentVerticalResolution /Value 2^>nul') do (
		set /a Row =1
		if !Row! == 1 set AdapterRAM=%%i
		if !Row! == 2 set CurrentBitsPerPixel=%%i
		if !Row! == 3 set CurrentHorizontalResolution=%%i
		if !Row! == 4 set CurrentRefreshRate=%%i
		if !Row! == 5 set CurrentVerticalResolution=%%i
		if !Row! == 6 set DriverDate=%%i
		if !Row! == 7 set DriverVersion=%%i
		if !Row! == 8 set MaxRefreshRate=%%i
		if !Row! == 9 set MinRefreshRate=%%i
		if !Row! == 10 set VideoName=%%i
		if !Row! == 11 set VideoProcessor=%%i
	)
)
if "!AdapterRAM:~0,1!" == "-" set AdapterRAM=
本文经用户投稿或网站收集转载,如有侵权请联系本站。