Help with a (hopefully) simple .vbs script

Fardringle

Diamond Member
Oct 23, 2000
9,200
765
126
I do a lot of support for remote computers of various makes and models, and at times I need to locate and reinstall drivers. Usually the easiest way to find the right drivers on OEM computers is with the brand name and serial number. With some help from Google and some trial and error I have managed to put together a few variations on a simple .VBS script that partially work on the Dell and HP systems I've tested, but don't give all of the information I want.

Script example 1:
Code:
Set objWMIservice = GetObject("winmgmts:\\.\root\cimv2")
set colBios = objWMIservice.ExecQuery("Select * from Win32_BIOS", ,48)
For each objBios in colBios
Wscript.echo "Manufacturer: " & objBios.manufacturer & VbCrLf & "Model Number: "  & VbCrLf & "Serial Number: " & objBios.serialnumber & VbCrLf & "System Bios: " & objBios.name
Next
Next
The problem I'm running into with this one is that while the Win32_BIOS environment contains information for SerialNumber, and Manufacturer, I can't seem to find the right variable to use (or if one exists) for the Model Number.

Script example 2:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
    Wscript.Echo "System Name: " & objComputer.Name & VbCrLf & "System Manufacturer: " & objComputer.Manufacturer & VbCrLf &  "System Model: " & objComputer.Model & VbCrLf & "Serial Number: " 
Next
As with the first one, the problem here is that I can't find what to use to pull the Serial Number out of Win32_ComputerSystem.

I know I can just put parts of both scripts into a single script to get all of the info, but I want it all to show on one pop-up and I can only manage to get it to work to show parts on two different pop-ups, like this:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
Wscript.Echo "System Name: " & objComputer.Name & VbCrLf & "System Manufacturer: " & objComputer.Manufacturer & VbCrLf&  "System Model: " & objComputer.Model
Next

set colBios = objWMIservice.ExecQuery("Select * from Win32_BIOS", ,48)
For each objBios in colBios
Wscript.echo "Serial Number: " & objBios.serialnumber
Next


So I guess the 'short version' of the question is if there is a way to get the manufacturer name, model number, and serial number to all show up in one simple pop-up window using .VBS or some other scripting option that will work on all Windows computers without requiring any extra installation of software, either by adding in the missing variables for either of these scripts (or using a better source if there is one), or by combining parts of the two to show up in just one pop-up.

I expect that there's something simple I'm missing but I'm really not a programmer so I'd appreciate any help you can give. Thanks
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
Concatenate the data into one string before doing a popup.

Code:
strComputer = "."
strProps = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
strProps = strProps + "System Name: " & objComputer.Name & VbCrLf & "System Manufacturer: " & objComputer.Manufacturer & VbCrLf&  "System Model: " & objComputer.Model & vbcrlf
Next

set colBios = objWMIservice.ExecQuery("Select * from Win32_BIOS", ,48)
For each objBios in colBios
strProps = strProps + "Serial Number: " & objBios.serialnumber
Next

Wscript.Echo strProps
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,619
4,533
75
Er, methinks the VBScript concatenation operator is "&".

Code:
strComputer = "."
strProps = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
strProps = strProps & "System Name: " & objComputer.Name & VbCrLf & "System Manufacturer: " & objComputer.Manufacturer & VbCrLf&  "System Model: " & objComputer.Model & vbcrlf
Next

set colBios = objWMIservice.ExecQuery("Select * from Win32_BIOS", ,48)
For each objBios in colBios
strProps = strProps & "Serial Number: " & objBios.serialnumber
Next

Wscript.Echo strProps
 

Fardringle

Diamond Member
Oct 23, 2000
9,200
765
126
Yep, that works, thanks!

I figured combining the two strings would work, but I just didn't know how. Thanks again! :)