Jump to content

VBScript to detect Computer model and install driver


Recommended Posts

Does anyone know how to create a VBScript that will allow me to detect the Computer Model and then install the specific drivers for that Model PC?

We have IBM T41,42,42,60,61 and HP Compaqs in our environment. I would like to have a script that would detect the model and install the audio, video, wireless, etc. drivers.

Any help would be appreciated.

Thanks.

Link to comment
Share on other sites


There are various ways of finding this information using WMI, although it can be found in different places depeding upon many factors.

Try something like this:

strComputer = inputbox("Type a computer name","Enter computer name")

if strComputer = "" then strComputer = "."

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM " _
& "Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately _
+ wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "Manufacturer: " & objItem.Manufacturer
WScript.Echo "Model: " & objItem.Model
Next

If that doesn't produce results you could take a look at Win32_Baseboard and/or Win32_SystemEnclosure.

Link to comment
Share on other sites

Thanks for this script, it works great. However, how can I integrate this script so that it will allow me to detect a specific driver for that model PC.

I am trying to set up runonce commands for our RIS setup and having a script that would detect the PC's and install driver specific to that model would be great.

There are various ways of finding this information using WMI, although it can be found in different places depeding upon many factors.

Try something like this:

strComputer = inputbox("Type a computer name","Enter computer name")

if strComputer = "" then strComputer = "."

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM " _
& "Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately _
+ wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "Manufacturer: " & objItem.Manufacturer
WScript.Echo "Model: " & objItem.Model
Next

If that doesn't produce results you could take a look at Win32_Baseboard and/or Win32_SystemEnclosure.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...