Linux
Apache
MySQL
PHP

CSS
XHTML1.1
XML/RSS

Creative Commons

2008-04-10 12:20:37

How many RAM slots do I have?

Sure, Windows can tell you the total amount of RAM in your computer, but sometimes you need to know how many slots you have and how many are used. I had that need today, especially so because I was nowhere near the physical machine to open the case and look. So, utilizing the Windows admin's best friend, VBScript with WMI, I wrote a small script to give me my answer. Just save the code as RAM.vbs and you're good to go.
'''''''''''''''''''''''''''''''' ' Make sure this runs in cscript '''''''''''''''''''''''''''''''' Set oSHell = CreateObject("Wscript.Shell") If Not Wscript.FullName = Wscript.Path & "\cscript.exe" Then oShell.Run "cmd.exe /k " & Wscript.Path & "\cscript.exe //NOLOGO " & Chr(34) & _ Wscript.scriptFullName & Chr(34),1,False Wscript.Quit 0 End If '''''''''''''''' ' Connect to WMI '''''''''''''''' Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") ''''''''''''''''''''''''''''''''''''' ' Determine the total number of slots ''''''''''''''''''''''''''''''''''''' Set colitems = objWMIService.ExecQuery("select * from Win32_PhysicalMemoryArray") For each objitem in colitems Wscript.echo objitem.MemoryDevices & " available slots" & vbNewLine Next ''''''''''''''''''''''''''''''''''''' ' Determine the size of each RAM chip ''''''''''''''''''''''''''''''''''''' Set colitems = objWMIService.ExecQuery("select * from Win32_PhysicalMemory") For each objitem in colitems wscript.echo objitem.DeviceLocator & " - " & (objitem.Capacity / 1048576) & "MB" Next


Back

7 comments


2008-04-11 09:19:27


Borat says...
sexy time

2008-04-11 09:20:15


Conrad says...
Am I your only fan?

2008-04-11 09:38:53


slonkak says...
According to the Apache logs, lots of people read my site, but hardly anyone comments.

2008-05-25 12:03:31


jimi says...
i read your site but its really only because i'm addicted to AOL IM buddy info

2008-05-29 08:14:47


Matt says...
I found your site today, does that count?

You also make it really easy to comment, which is nice. Some people want you to register, fill out a captcha, and solve for 'x'. Bah.

2008-05-29 08:48:51


slonkak says...
I make use of a reverse captcha (to fend off some bots) and a spam filter I wrote (to fend off most other bots). So far, it's working well. My plan is to keep commenting simple, so as long as my spam filtering is working, it will remain simple.

2010-09-01 04:45:55


Caza says...
After a trawl through several websites I finally managed to get code that correctly displayed the number of memory available on a PC. Well done you!

Post a comment!

Name:
Comment: