Sub GetMemory()
Dim oInstance As Object, colInstances As Object
Dim totalMem As Single, availMem As Single
Set colInstances = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_PhysicalMemory")
For Each oInstance In colInstances
totalMem = totalMem + oInstance.Capacity / 1024 / 1024
Next
Set colInstances = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each oInstance In colInstances
availMem = availMem + oInstance.FreePhysicalMemory / 1024
Next
MsgBox (totalMem & " " & availMem)
End Sub