Skip to content

Instantly share code, notes, and snippets.

@cornfred
Created September 23, 2013 23:36
Show Gist options
  • Save cornfred/6678466 to your computer and use it in GitHub Desktop.
Save cornfred/6678466 to your computer and use it in GitHub Desktop.
VBScript to gather windows computer information via WMI. Can take a Run it with: cscript cinfo.vbs COMPUTERNAME OR cscript cinfo.vbs
if Wscript.Arguments.count > 0 then
strComputer = Wscript.Arguments(0)
else
Wscript.StdOut.Write "Please enter a computer name: "
strComputer = Wscript.StdIn.ReadLine
end if
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
Set colSMBIOS = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
Set colItems = objWMIService.ExecQuery(_
"Select * from Win32_Processor")
Set shell = CreateObject("WScript.Shell")
Set getOSVersion = shell.exec("%comspec% /c ver")
version = getOSVersion.stdout.readall
Select Case True
Case InStr(version, "n 5.0") > 1 : GetOS = "Windows 2000"
Case InStr(version, "n 5.1") > 1 : GetOS = "Windows XP"
Case InStr(version, "n 6.0") > 1 : GetOS = "Windows Vista"
Case InStr(version, "n 6.1") > 1 : GetOS = "Windows 7"
Case InStr(version, "n 6.2") > 1 : GetOS = "Windows 8"
Case Else : GetOS = "Unknown"
End Select
wscript.echo GetOS
For Each objComputer in colSettings
Wscript.Echo "System Name: " & objComputer.Name
Wscript.Echo "Total Physical Memory: " & _
Round(objComputer.TotalPhysicalMemory / 1073741824, 2) & "GB Usable"
Next
For Each objSMBIOS in colSMBIOS
Wscript.Echo "Serial Number: " _
& objSMBIOS.SerialNumber
Next
For Each objItem in colItems
Wscript.Echo "Processor Name: " & objItem.Name
Wscript.Echo "Maximum Clock Speed: " _
& Round(objItem.MaxClockSpeed / 1000, 1) & " GHz"
Next
wscript.echo version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment