WMIC命令显示的值不正确?

时间:2018-07-11 10:54:57

标签: batch-file ram audit wmic

我们使用的产品会向我们的平台报告有关审核信息,例如RAM和CPU。

但是,在RAM方面,我们得到了不同寻常的结果。

产品使用以下命令:wmic computersystem get totalphysicalmemory

,输出值为2.3GB RAM

但是它已安装4GB。我们使用此信息为客户创建路线图,因此需要准确。知道为什么吗?

2 个答案:

答案 0 :(得分:0)

wmic memorychip get capacity

来源:How can I get total physical memory using Windows cmd

使用Hybrid [batch-Vbscript]文件,您可以执行以下操作:

@echo off
Mode 55,10 & color 0A
Title TotalPhysicalMemory ^& Memorychip Capacity
Set "WMIC_TOTMEM=wmic ComputerSystem get TotalPhysicalMemory /format:Value"
Set "WMIC_Capacity=wmic memorychip get capacity /format:Value"
Set "CAP=Capacity"
Set "TOT=TotalPhysicalMemory"
Call :GetTOTMEM %TOT% TotalPhysicalMemory
Call :GetCapacityMem %CAP% Capacity
echo(
Call :Convert %TotalPhysicalMemory% TotalPhysicalMemory_Converted
Call :Convert %Capacity% Capacity_Converted
echo   -------------------------------------------------
echo     TotalPhysicalMemory = %TotalPhysicalMemory%
echo     Memorychip Capacity = %Capacity%
echo   -------------------Converted---------------------
echo     TotalPhysicalMemory = %TotalPhysicalMemory_Converted%
echo     Memorychip Capacity = %Capacity_Converted% 
echo   -------------------------------------------------
pause>nul & Exit
::-------------------------------------------------------
:GetCapacityMem
FOR /F "tokens=2 delims==" %%I IN (
  '%WMIC_Capacity% ^| find /I "%~1" 2^>^nul'
) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%2=%%A"
Exit /b
::-------------------------------------------------------
:GetTOTMEM
FOR /F "tokens=2 delims==" %%I IN (
  '%WMIC_TOTMEM% ^| find /I "%~1" 2^>^nul'
) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%2=%%A"
Exit /b
::-------------------------------------------------------
:Convert
Set "VBS=%Temp%\%Random%.vbs"
(
    echo wscript.echo Convert("%~1"^)
    echo 'Function to format a number into typical size scales
    echo Function Convert(iSize^)
    echo    aLabel = Array("bytes", "KB", "MB", "GB", "TB"^)
    echo    For i = 0 to 4
    echo        If iSize ^> 1024 Then
    echo            iSize = iSize / 1024
    echo        Else
    echo            Exit For
    echo        End If
    echo    Next
    echo    Convert = Round(iSize,2^) ^& " " ^& aLabel(i^)
    echo End Function
)>"%VBS%"
for /f "delims=" %%a in ('Cscript //NoLogo "%VBS%"') do ( set "%2=%%a" )
Del "%VBS%"
Exit /b
::-------------------------------------------------------

答案 1 :(得分:0)

我不知道<!DOCTYPE html> <html> <head> </head> <body> <form name="myForm" action="/action_page.php" method="post"> Name: <input type="text" name="fname"> <input type="submit" value="Submit"> </form> </body> </html> 返回的数字实际上代表什么,但是我认识到结果数字要比wmic ComputerSystem get TotalPhysicalMemory给定的数字求和要少,该数字返回每个已安装内存的大小设备。

这里是一个纯批处理脚本,它确定了总的内存容量(请参阅说明性注释),解决了对32位带符号整数的数值的限制:

wmic MemoryChip get Capacity