Hello all,
I created a VBS script that we could have our Desktop team utilize for gathering PC information for documentation purposes. Everything works just the way I wanted it to, except there's one part that bugs me.
When I display in objOperatingSystem.Name in a Msgbox it gives me the correct OS, but it adds |C:\WINDOWS|\Device\harddisk0\Parition1 at the end. Is there a way to remove this extra information from being added? Any help would be appreciated as I've looked around and haven't really found others wanting to do the similar thing.
My Script for Collecting Computer Information and displaying it in a msgbox format for a Tech.
Option Explicit
Dim strComputer, strOSName, strOSVersion, strServicePack, strHostName, strManufacturer, strModel, strRAM, strProcessor, strCPUManufacturer, strMACAddress
Dim objWMIService, objOperatingSystem, objComputer, objItem, colSettingsOS, colSettingsSys, colSettingsCPU, colItems, WShNetwork, wmiQuery, intRamMB, colComputer
Dim strintRAM, strData, objMACAddress, i
'Set Variables
strComputer = "."
' Gather system information via WMI
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettingsOS = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") ' Query OperatingSystem component
For Each objOperatingSystem in colSettingsOS
strOSName = "OS Name: " & objOperatingSystem.Name
strOSVersion = "OS Version: " & objOperatingSystem.Version
strServicePack = "Current ServicePack: " & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion
Next
Set colSettingsSys = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettingsSys
strHostName = "Computer Name: " & objComputer.Name
strManufacturer = "Computer Manufacturer: " & objComputer.Manufacturer
strModel = "Computer Model: " & objComputer.Model
strRAM = "Memory in Computer: " & int((objComputer.TotalPhysicalMemory) /1048576)+1 & intRamMB & " MB"
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
strData = strData & "Description: " & objItem.Description & vbcrlf
If Not IsNull(objItem.IPAddress) Then
For i = 0 To UBound(objItem.IPAddress)
strData = strData & "IP address: " & objItem.IPAddress(i) & vbcrlf
Next
End If
strData = strData & "Adapter MAC: " & objItem.MACAddress & vbcrlf & vbcrlf
Next
Set colSettingsCPU = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colSettingsCPU
strCPUManufacturer = "CPU Manufacturer: " & objItem.Manufacturer
strProcessor = "CPU Model: " & objItem.Name
Next
MsgBox strOSName & vbLf & strServicePack & vbLf & strHostName & vbLf & strManufacturer & vbLf & strModel & vbLf & strRam & vbLf & strCPUManufacturer & vbLf & strProcessor & vbLf & vbLf & (strData), vbOkOnly, "Description Here for MessageBox Header"
Wscript.Quit(0)