Physical RAM on win32

Alex Martelli aleax at
Fri Jan 11 15:28:16 CET 2002

"David Sparrman" <David.Sparrman at> wrote in message
news:22034d27.0201110536.37eb8f25 at
> Hello,
> Is there a simple way to check the amount of physical RAM on a win32
> computer?

If you have installed WMI (Windows Management Instrumentation) there
is a way to check just about everything (via Com/Automation), although
simplicity is in the eye of the beholder.  You can get WMI from MS's
site, if you haven't installed it yet.

>>> from win32com.client import GetObject
>>> cses = GetObject("WinMgMts:").InstancesOf("Win32_ComputerSystem")
>>> for cs in cses: break

Now you have in variable cs a WMI object of Win32_ComputerSystem class,
and you can query it to your heart's contents about all of its properties.
See for example the summary at URL:

>>> pc.TotalPhysicalMemory
>>> long(pc.TotalPhysicalMemory)/1024

etc, etc.

For a general introduction to "Microsoft Windows Management Instrumentation
Scripting", see (a single URL, split by posting):

It's a huge, omni-comprehensive, some would say over-engineered system,
but once you have installed it correctly it does make it a snap to
perform every kind of monitoring and sysadm task you can possibly
imagine (and then some).  All you need to use WMI is any COM-capable
scripting language, and Python fits the bill wonderfully well.


More information about the Python-list mailing list