WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Physical Memory

 Keywords: Get Physical Memory Limit Win32_PerfRawData_PerfOS_Memory Available Bytes Cache AvailableBytes CacheBytes Win32_Process WorkingSetSize WorkingSet Size Huge Number huge_Divide huge_Add Bytes MB BinaryAlloc BinaryRead

Memory Limits for various Windows platforms: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx

; Get Physical Memory in Bytes
AddExtender("wwhug34i.dll")  ; Huge Math WIL extender dll.
UsePrecision = @TRUE ; Fixed precision
MaxiDivPrecision = 0
FixedPrecision = 0
AddSeparator = @TRUE
SeparatorFormat = @FALSE
Decimal = 0
Thousands = 0
huge_SetOptions (UsePrecision, MaxiDivPrecision, FixedPrecision, AddSeparator, SeparatorFormat, Decimal, Thousands)


objLocator = ObjectCreate("WbemScripting.SWbemLocator")
objService = objLocator.ConnectServer(".","root/cimv2","","")
objSecurity = objService.Security_
objSecurity.ImpersonationLevel = 3
query = "SELECT * FROM Win32_PerfRawData_PerfOS_Memory"

; query instances
ForEach objInstance In objService.ExecQuery(query)
   availableBytes = objInstance.AvailableBytes
   cacheBytes =  objInstance.CacheBytes
Next

query = "SELECT * FROM Win32_Process"
totalworkset = 0
; query instances
ForEach objInstance In objService.ExecQuery(query)
   totalworkset = huge_Add(objInstance.WorkingSetSize, totalworkset)
Next

physicalmem = huge_Add( huge_Add( availableBytes, cacheBytes ), totalworkset )
str = StrCat("Available Bytes    : ",availableBytes,@CRLF,"Cache Bytes         : ",cacheBytes,@CRLF,"Working set total     : ", totalworkset,@CRLF,"_______________________",@CRLF,"Physical Memory    : ",physicalmem)
Message("Approximation of Physical Memory",str)

Exit

Article ID:   W18474
Filename:   Get Physical Memory.txt
File Created: 2012:04:12:08:17:06
Last Updated: 2012:04:12:08:17:06