java wmi获取硬件信息,如何使用Java或CMD获取PC硬件信息

I am creating a Java Desktop Application that is to report the Performance & Statistics of the Windows Machine (XP, Vista and W7).

Using Java or the Command Line how do I get the following information:

Manufacturer (Dell, HP...)

Modal Number

Processor Type

Processor Size

System Type

Storage Space

RAM Total

RAM Free or Used

And a reference page for this would be great, in case I find more information I want to list.

解决方案

Most of this should be queryable with WMI (which is what systeminfo very likely uses under the hood anyway – it just tends to gather all there is instead of specific information).

I hacked together the following small batch file. Not quite sure what you mean with Processor Size – no software will go into the computer case and measure the die dimensions, but maybe this comes close. You can do a set at the end of the batch file to view all created environment variables. Maybe some of them help:

@echo off

setlocal enableextensions enabledelayedexpansion

for /f "delims=" %%l in ('wmic computersystem get Manufacturer^,Model^,SystemType^,TotalPhysicalMemory /format:list') do >nul 2>&1 set "System_%%l"

for /f "delims=" %%l in ('wmic cpu get * /format:list') do >nul 2>&1 set "CPU_%%l"

for /f "delims=" %%l in ('wmic os get FreePhysicalMemory^,TotalVisibleMemorySize /format:list') do >nul 2>&1 set "OS_%%l"

set /a OS_UsedPhysicalMemory=OS_TotalVisibleMemorySize-OS_FreePhysicalMemory

for /f "delims=" %%l in ('wmic volume get DriveLetter^,FreeSpace /format:list') do (

>nul 2>&1 set "TEMP_%%l"

if "!TEMP_DriveLetter:~1,1!"==":" if defined TEMP_FreeSpace set StorageSpace_!TEMP_DriveLetter:~0,2!=!TEMP_FreeSpace:~0,-1!&set TEMP_DriveLetter=&set TEMP_FreeSpace=

)

echo Manufacturer: %System_Manufacturer%

echo Model: %System_Model%

echo Processor Type: %PROCESSOR_ARCHITECTURE%

echo Processor Size: %CPU_AddressWidth%

echo System Type: %System_SystemType%

echo Storage Space:

set StorageSpace_

echo RAM total: %OS_TotalVisibleMemorySize% KiB

echo RAM free: %OS_FreePhysicalMemory% KiB

echo RAM used: %OS_UsedPhysicalMemory% KiB

Side note: This is free from locale-specifics, so it should work everywhere (as opposed to things like dir | find "free" for example). Code can be found in my SVN repository.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值