Note that all of these return kilobytes.
wmic method
wmic os get TotalVisibleMemorySize,FreePhysicalMemory
I'm not sure TotalVisibleMemorySize is correct, but it does appear to show physical memory on my system.
VBScript method
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx
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
PowerShell method
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx
# 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 condensed (called from cmd)
powershell.exe -c (Get-WmiObject -Class Win32_OperatingSystem).FreePhysicalMemory
memcan't handle 192 GB of RAM? – iglvzx Apr 30 '12 at 5:51mem.exeis a 16-bit MS-DOS executable, you are probably right. – grawity Apr 30 '12 at 7:58memisn't useful on 32 bit windows either since it only reports the status of the 16 bit dos virtual machine. – psusi Apr 30 '12 at 13:24