Observe que todos esses retornam kilobytes.
wmic
method
wmic os get TotalVisibleMemorySize,FreePhysicalMemory
Não tenho certeza se o TotalVisibleMemorySize está correto, mas ele aparece para mostrar a memória física no meu sistema.
Método VBScript
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
Wscript.Echo "Available Physical Memory: " & _
objOperatingSystem.FreePhysicalMemory
Next
Método do PowerShell
# Get-FreeMemory.ps1 # Sample using PowerShell # 1st sample from http://msdn.microsoft.com/en-us/library/aa394587 # Thomas Lee $mem = Get-WmiObject -Class Win32_OperatingSystem # Display memory "System : {0}" -f $mem.csname "Free Memory: {0}" -f $mem.FreePhysicalMemory
This script produces the following output:
PS C:\foo> .\get-freememory.ps1 System : COOKHAM8 Free Memory: 2776988
PowerShell condensado (chamado de cmd)
powershell.exe -c (Get-WmiObject -Class Win32_OperatingSystem).FreePhysicalMemory