Other Programming

Computer Information using WMI Scripting

A few years ago, I worked at the OIT Help Desk at Central Michigan University.  While there, I was asked to write a little utility that would pull information about the machine out of the system.  In order to do so, I learned VBScript and the WMI library that comes with Windows.  WMI is really handy for projects like this because it allows you to pull machine specific information in an easy way.  For instance, let’s say I want to get the machine name:

Option Explicit
Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strComputer

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colComputer = objWMIService.ExecQuery _
(“Select * from Win32_ComputerSystem”)

For Each objComputer in colComputer
Wscript.Echo “System Name: ” & objComputer.Name _
& vbCr & “Total RAM ” & objComputer.TotalPhysicalMemory


Easy as pie.  The only problem is that you have to have a loop in there.   Even with only 1 computer.

By Jack Slingerland

Founder of Working and living in Raleigh, NC. I manage a team of software engineers and work in Python, Django, TypeScript, Node.js, React+Redux, Angular, and PHP. I enjoy hanging out with my wife and son, lifting weights, and advancing in my free time.