Try this:
 Code:
$SysMemory = val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
If $SysMemory = 0
  $SysMemory = Memory()
EndIf
Be sure to download and insert the Memory UDF. The one I wrote a few years ago was discussed quite a bit and found to be the most consistent and accurate in its reporting. I haven't used it in a while, but just tested it on Windows 8 and Server 2012 before responding to your post and it reported accurate values. Download the latest version from the Kixtart UDF Library on my web site.

Note that this UDF returns System RAM, not Installed RAM Modules (the amount of RAM available to the system, not including shared Video or BIOS Cache). In my Server 2012 test, there is 4G RAM physically installed - 4x1G modules. The RAM reported was 4032, which is 64MB shy of the full amount. This is the memory "hole" for the BIOS. On my workstation, with 4G RAM, it reports 3327MB, the result of my video card sharing a 768MB block of RAM. If you are looking for total Installed RAM, you can fudge the result a bit with the following code. This assumes that you know the smallest RAM module installed in the hardware you are interrogating. For example, if you've determined that the smallest RAM module is 512MB for the majority of your systems, then set $MSize to 512. The result will be pretty accurate, but could be up to 512MB short, particularly with systems using shared video RAM.
 Code:
$MSize = 512				; Smallest RAM module in service

$M = Memory()				; get available RAM in MBytes
$Ma = $M / $MSize			; Divide by smallest module size
If $M Mod $MSize $Ma = $Ma + 1 EndIf	; If a fractional module is detected, add another full module
$Ma = $Ma * $MSize			; calc installed RAM by multiplying modules * ModuleSize

'  Reported: ' $M ?
'  Adjusted: ' $Ma ?
'Difference: ' 4096 - $Ma ?
With the code above (knowing that all of my systems have either 1 or 4G modules), both computers properly report 4096MB installed.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D