How to get PC Hardware information using Java or CMD

耗尽温柔 提交于 2019-12-04 06:09:22

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.

Deepak

Manufacturer

systeminfo | find "System Manufacturer"

Model Number

systeminfo | find "System Model"

Processor Type

echo %PROCESSOR_IDENTIFIER% %PROCESSOR_LEVEL%

Processor Size

systeminfo | find "Processor"

System Type

systeminfo | find "System type"

Storage Space

dir | find "free"

OR

fsutil volume diskfree C:

RAM Total

systeminfo | find "Total Physical Memory"

RAM Free or Used

systeminfo | find "Available Physical Memory"

Would psinfo from sysinternals do what you want? You can run it from your server to query each PC. http://technet.microsoft.com/en-us/sysinternals/bb897550

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!