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

System Information

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

How to Retrieve Physical memory.

Keywords: total Physical available memory 

TRY THIS:

See the Process Extender functions. You can approximate the physical memory on a machine by querying the following performance counters and summing the total of the 3 following counters:

Memory\Available Bytes
Memory\Cache Bytes
Process\Working Set\ _Total 
Here is some sample code..

NOTE: this code can be used to get physical memory on Local *or* Remote machines....

AddExtender("wwprc44I.dll")
if WinVersion(4) == 4; NT
   availablebytes = tGetData("\\Machine\Memory\Available bytes",0)/1024
   cachebytes = tGetData("\\Machine\Memory\Cache bytes",0)/1024
   totalworkset = tGetData("\\Machine\Process(_Total)\Working Set",0)/1024
   physicalmemMB = (availablebytes + cachebytes + totalworkset)/1024
   str = strcat("Available bytes     : ",availablebytes,@CRLF,"Cache bytes         : ",cachebytes,@CRLF,"Working set total  : ", totalworkset,@CRLF,"_______________________",@CRLF,"Physical Memory (MB): ",physicalmemMB)
   Message("Approximation of Physical Memory",str)
else
  Message("tGetData", "Is designed to run on NT")
endif
exit

OR THIS:

This code automates the Control panel applets with the Control manager extender.

;gets total physical memory on Windows NT 4.0
AddExtender("wwctl34I.dll")
Run("winmsd.exe", "");can change to Runhide once debugged......
title="Windows NT Diagnostics"
WinWaitExist(title,10)
titlewnd=DllHwnd(title)
tabtitle="Memory"
systabwnd=cWndByClass(titlewnd,"SysTabControl32")
cSetTabItem(systabwnd,5)
chd2=cWndbySeq( titlewnd, 1)
total_mem_hndl=cWndById(chd2, 10288 ) 
avail_mem_hndl=cWndById(chd2, 10289 )
filecache_hndl=cWndById(chd2, 10290 )
;get physical memory
total_mem=cWndInfo(total_mem_hndl,0)
avail_mem=cWndInfo(avail_mem_hndl,0)
filecache=cWndInfo(filecache_hndl,0)
Message("Physical memory (KB)",strcat("Total: ", total_mem, @CRLF,"Available: ",avail_mem,@CRLF,"File Cache: ",filecache))
exit



Article ID:   W14612
Filename:   Retrieve Physical memory.txt
File Created: 2013:04:01:09:17:26
Last Updated: 2013:04:01:09:17:26