Monday, October 18, 2010

VBScript: List Type, Slot and Capacity of Installed RAM.

This is just a quick script that I've found useful when I need to know what kind of RAM is installed on a PC (DRAM, SDRAM, etc.), where it is (which slot) and in what capacity (the ever-important GB's). This can be helpful in determining if a user's PC meets the minimum requirements for a particular install, or when determining if a user's PC could benefit from an upgrade. Also useful for general inventory purposes as, unlike many of the methods that display memory, this one will tell you how many chips and of what denomination the user has.


'-----------------Memory Checker------------------------------------------
Dim objIE, objDoc, popDebug
popDebug = True
strComputer = "."
memType = array("Unknown","Other","DRAM","Synchronous DRAM","Cache DRAM","EDO","EDRAM","VRAM","SRAM","RAM","ROM","Flash","EEPROM","FEPROM","EPROM","CDRAM","3DRAM","SDRAM","SGRAM","RDRAM","DDR","DDR-2")


Set ObjWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set ColItems = ObjWMI.ExecQuery("Select * from Win32_PhysicalMemory")

For Each Item in ColItems
pop("Memory Type: " & memType(Item.MemoryType))
pop("Slot: " & Item.DeviceLocator)
pop("Capacity: " & (Item.Capacity / 1048576) / 1024 & " GB")
pop("")
Next

function pop(strText)
if popDebug = True then
if Not IsObject(objIE) then
Set objIE = wscript.CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
objIE.Visible = 1
objIE.ToolBar = False
objIE.Width = 400
objIE.Height = 500
Set objDoc = objIE.Document
objDoc.Open
'objDoc.Writeln "<HEAD><TITLE>Immediate Window - Debugger</TITLE></HEAD>"
end if
objDoc.Writeln strText & "<br/>"
end if
end function

'-----------------Memory Checker------------------------------------------

Enjoy,

No comments: