VB Script to verify video driver version and then update if it's not correct
Posted on 2011-09-14
I am trying to create a vbscript that would check the video driver version and then update the driver if it is not the correct version. I have a few different machine models and various display adapters. It will need to verify the hardware and driver version then install the correct driver unattended. Below is the vbs that I started which will identify the video driver version and model. Where I am stuck is how to get the script to use the info to verify and then carry out the install. I also need to ensure the event is captured in the event viewer which I believe is almost complete but not sure if a failure is recorded. Can someone please help with reviewing this to see what I am missing. I can't seem to figure out how to get it to verify then install from a network location. Also how to handle other models? Do I just cut and paste the process and change the else command?
Sorry - please bear with me - but I am pretty new to vbscript and I still have ALOT to learn as you will see..Honestly, I am truly amazed I even got this far on my own. I am open to suggestions. Many Thanks!
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_VideoController")
For Each objItem in colItems
For Each strCapability in objItem.AcceleratorCapabilities
Wscript.Echo "Accelerator Capability: " & strCapability
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Driver Date: " & objItem.DriverDate
Wscript.Echo "Driver Version: " & objItem.DriverVersion
Wscript.Echo "INF Filename: " & objItem.InfFilename
Wscript.Echo "Installed Display Drivers: " & _
Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
WScript.Echo "Manufacturer: " & objItem.Manufacturer
WScript.Echo "Model: " & objItem.Model
Const EVENT_SUCCESS = 0
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
"Video Driver Update Successfully Installed by IT."
If driver version Is Not 188.8.131.521 And the model =nvidia Then install (\\server\data\files\drivers\nvidia\setup.msi /qn)